LA4254 STL优先队列+二分答案
来源:互联网 发布:淘宝加盟的骗局揭秘 编辑:程序博客网 时间:2024/04/30 19:27
/*题意:有n个任务,给出了每个任务的起始时间和终止时间还有工作量w,处理任务的速度为s时,任务会花费 w / s时间,然后每个任务都要在规定时间内完成,但任务可以不用连续时间块内完成,要求出让所有时间都顺利完成的最大速度的最小值。*/#include<iostream>#include<cstdio>#include<cstdlib>#include<queue>#include<algorithm>using namespace std;struct node{int st,en,w;friend bool operator < (const node &a,const node &b){return a.en>b.en;} };struct node p[10000+10];int n;int cmp(node a,node b){return a.st < b.st;}bool work(int x){priority_queue <node> q;int t=1,i=1;while(1){while (i<=n && p[i].st<=t)q.push(p[i++]);int s=x;while(s!=0 && !q.empty()){node u=q.top();q.pop();int tmp=min(s,u.w);s-=tmp;u.w-=tmp;if(u.w!=0)q.push(u);} t++;if(!q.empty() && q.top().en<=t)return false;if(q.empty() && i==n+1)return true;}}int main(){int T;cin>>T;while( T-- ){cin>>n;int l=0,r=100000;for (int i = 1; i <= n; i++)scanf("%d%d%d", &p[i].st, &p[i].en, &p[i].w);sort(p+1,p+n+1,cmp);while(l<r){int mid=(l+r)/2;if(work(mid))r=mid;else l=mid+1;}cout<<l<<endl;}return 0;}
0 0
- LA4254 STL优先队列+二分答案
- LA4254 Processor (贪心+二分)
- stl中的优先队列
- stl 优先队列
- STL 优先队列
- STL之优先队列
- STL priority_queue 优先队列
- STL-->优先队列
- STL之优先队列
- STL priority_queue 优先队列
- 优先队列stl 模板
- STL优先队列使用
- STL 优先队列使用
- STL优先队列
- 优先队列stl
- STL中的优先队列
- STL中优先队列
- 优先队列STL
- ubuntu搭建单机版hadoop
- eclipse[Open In Explorer]
- elasticsearch 使用bulk导入数据
- Android ClassyShark vs ApkTool
- FZU ~APTX4869
- LA4254 STL优先队列+二分答案
- javaIO关于文件操作(读取,写入,复制,遍历所有文件)
- HD Tune结合硬盘再生器HDDREG快速修复硬盘错误
- LeetCode 280. Wiggle Sort
- php和lua的变量作用域
- 「JavaScript里的面向对象」— 5.原型模式
- 关于NSBundle获取文件路径的问题
- 自定义OpenStack Horizon(Mitaka)
- 废掉Minifilter和Sfilter 支持x64