负载均衡
有不同的电脑以及文件需要处理
每个电脑都是有限制容量,文档传输也需要一定的时间
每一次输出结果
这个用堆来模拟,优先队列,把最小的提出来,如果右端点<=当前,那之前的处理没啥用,还要还原
如果没有
那就需要兼顾之前的容量
#include#include #include using namespace std; typedef pair<int,int> PAII; const int N=1e5+10; int g[N]; int main(){ priority_queue ,greater > h[N]; int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%d",&g[i]); while(m--) { int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d); while(h[b].size()&&h[b].top().first<=a)//这是之前的操作,如果和后面没有联系就可以删掉,还记得要还原 { g[b]+=h[b].top().second; h[b].pop(); } if(g[b] "-1\n"); else//当前的 { g[b]-=d; h[b].push({a+c,d}); printf("%d\n",g[b]); } } return 0; } /* 模拟 */