当前位置:网站首页>[蓝桥杯省赛] 负载均衡
[蓝桥杯省赛] 负载均衡
2022-04-22 06:06:00 【Lupin123123】
很好的一道模拟题
#include<bits/stdc++.h>
#define FAST ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int maxn = 2e5+5;
int n,m;
int s[maxn];
priority_queue<PII, vector<PII>, greater<PII> > q[maxn];
int main()
{
// freopen("1.in","r",stdin);
// freopen("1.txt","w",stdout);
scanf("%d%d",&n,&m);
for (int i=1; i<=n; i++) scanf("%d",&s[i]);
for (int i=1; i<=m; i++){
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
while(q[b].size() && q[b].top().first<=a){
s[b]+=q[b].top().second;
q[b].pop();
}
if (s[b]<d) printf("-1\n");
else{
q[b].push({
a+c,d});
s[b]-=d;
printf("%d\n",s[b]);
}
}
return 0;
}
版权声明
本文为[Lupin123123]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_28972011/article/details/123958428
边栏推荐
- Install Matplotlib and bug resolution in the specified environment
- Clark transform of PMSM FOC control MATLAB / Simulink simulation
- 【AI视野·今日Robot 机器人论文速览 第二十九期】Mon, 14 Feb 2022
- C#窗体设计 鼠标任意 拖拽 窗体大小、控件联动
- 图片合成视频
- 人这一生啊
- 让MATLAB2018b支持VS2019的mex配置
- ROS系列(一):ROS快速安装
- PCB上邮票孔的添加方式,你真的做对了吗……
- 【AI视野·今日NLP 自然语言处理论文速览 第二十九期】Mon, 14 Feb 2022
猜你喜欢
随机推荐
PMSM FOC控制 Matlab/Simulink仿真之反Clark变换
STM32 高级定时器 COM事件
jupyter notebook修改配置文件设置启动目录无效
【Latex】分数写法区别
How to discover and learn the story hidden behind the published metagenome articles
如何在CMake项目中引入OpenCV
Win10启动VMware虚拟机开机秒蓝屏问题完美解决
树莓派3B通过mentohust登录锐捷校园网有线端,并创建WIFI(开热点)供其他设备使用,同时实现开机自启动
新型实例分割网络PANet(Path Aggregation Network for Instance Segmentation)源码和更新详解
卷积神经网络基础知识
PCBA上電容開裂短路,怎麼又是設計的錯?
Development of two stage target detection technology (I) r-cnn and spp net
示波器只能测波形-格局小啦
paddlepaddle模型转onnx
关于Mask-Rcnn中标注工具VIA(VGG Image Annotator)使用的详解
Evaluation indexes in multi label classification: accuracy, cross entropy, cost function
【数学建模】我的数模记忆
【AI视野·今日Robot 机器人论文速览 第三十一期】Fri, 15 Apr 2022
Lachnospira, the core genus of intestinal bacteria
宏基因组组装质量评估新方法-MAGISTA









