当前位置:网站首页>[Blue Bridge Cup] load balancing
[Blue Bridge Cup] load balancing
2022-04-22 07:04:00 【Lupin123123】
A good simulation problem
#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://yzsam.com/2022/04/202204220604096404.html
边栏推荐
- STM32 TIM 定时器 OCREF 输出配置 TIMx->CCER
- QT basic knowledge summary (continuous refresh)
- How can we improve the channel loss of high-speed signal
- MA8608奇岩USB 2.0高速4端口USB HUB集线器控制器芯片方案
- CAN总线记录诊断助手
- Typec转HDMI 4K30HZ扩展芯片方案CS5261和CS5266设计参数及电路对比
- STM32 clock division Tim_ Detailed description of clockdivision configuration and use
- Before glide 4.0, glide set the round picture and set the round corner of the picture (four corners can be set together or some corners can be set separately)
- 疫情环境下工程机械中的透传云网关远程程序升级方案
- TD041S485H完全兼容ISO3080, ISO3086 ISO3082, ISO3088
猜你喜欢

GridView of QML realizes sliding grid layout

Typec转HDMI 4K30HZ扩展芯片方案CS5261和CS5266设计参数及电路对比

谱瑞PS8625替代方案|PS8622替代方案|高性价比EDP转LVDS转接板方案CS5211设计开发

I've gone too far, but I can't get out of the routine of ddrx debugging

在消防联网(楼宇、工厂、海上风电、管廊等)中CAN光纤转换器、CAN总线光端机典型应用案例

Matlab Simulink installation compiler MinGW

CAN光纤光端机在光电滑环中的应用

CAN光端机在消防水炮中的应用

Replace rtd2171u | cs5266 design circuit | type C to HDMI scheme | cs5266an

消防设备光纤联网CAN转光纤转换器
随机推荐
Replace rtd2171u | cs5266 design circuit | type C to HDMI scheme | cs5266an
Audio type 523 + VGA + 5 + HDC to 5 + VGA
Matlab GUI 缩放-部分控件缩放、部分控件不缩放-设计教程
SSS1700
PCBA上電容開裂短路,怎麼又是設計的錯?
PMSM FOC控制 Matlab/Simulink仿真之Clark变换
Middle note output in C form design
Before glide 4.0, glide set the round picture and set the round corner of the picture (four corners can be set together or some corners can be set separately)
Solution: attributeerror: module 'yaml' has no attribute 'csafeloader‘
Add files to the server
Stm32wb55 RTT based ble sample making process
SSS1700
QT qfile deletes the last n bytes of data in the file
QT basic knowledge summary (continuous refresh)
SSS1700 QFN36单芯片设计一款USB Typec耳机|支持线控和欧美规自动切换USB耳机方案
[mcukeys] a general, flexible, configurable and portable implementation of key event processing
Conflict between glide 4.0 and fillet clipping centercrop
C # form design: drag the form size and control linkage arbitrarily with the mouse
同一个过孔会有不同的阻抗???
MDK scope joint debugging RTT mode multi-channel