UvaLive-4254-Processor
来源:互联网 发布:mac怎么装正版office 编辑:程序博客网 时间:2024/05/30 22:44
用二分法可以做~
代码:
#include<cstdio>#include<queue>#include<iostream>#include<algorithm>#include<queue>using namespace std;struct node{ int l,r,w; bool operator < (const node &a)const {return r>a.r; }}a[10001];int n;priority_queue<node> q;bool cmp(node a,node b){ return a.l<b.l;}bool check(int mid){ int i=0,j=0; while(!q.empty()) q.pop(); while(1) {while(i<n&&a[i].l<=j) q.push(a[i++]);int now=mid;while(now!=0&&!q.empty()){ node ita=q.top(); q.pop(); int m=min(now,ita.w); now-=m; ita.w-=m; if(ita.w!=0)q.push(ita);}j++;if(!q.empty()&&q.top().r<=j) return false;if(q.empty()&&i==n) return true; }}int main(){ int cas; scanf("%d",&cas); while(cas--) {scanf("%d",&n);int sum=0;for(int i=0;i<n;i++){ scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].w); sum+=a[i].w;}sort(a,a+n,cmp);int l=0,r=sum,ans=sum;while(l<=r){ int mid=(l+r)>>1; if(check(mid)) {ans=mid;r=mid-1; } elsel=mid+1;}printf("%d\n",ans); } return 0;}
- UvaLive-4254-Processor
- UVALive - 4254 Processor
- UvaLive 4254 Processor 优先队列
- UVALive - 4254 Processor 二分+优先队列
- uvalive 4254 Processor处理器 (二分模拟+贪心)
- LA 4254(p80)----Processor
- LA 4254 Processor 贪心+二分 *
- UVA 1422 (LA 4254)- Processor
- LA 4254 Processor(二分+贪心+优先队列)
- 处理器(Processor,Seoul 2008,LA 4254)
- LA 4254 Processor (单调队列 + 二分)
- uvalive 4254(二分)
- UVALive 4254 二分
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- hive 配置参数说明
- YearsBetween、MonthsBetween ... YearSpan、MonthSpan ... 间隔时间
- HDU3374(String Problem)字符串-最小表示法+KMP
- DictForGeeks,我自己写的自定义词库的词典,支持英-中,中-英,也可以当电话本用。
- 韩信走马分酒问题(回溯)
- UvaLive-4254-Processor
- myeclipse新建webproject没反应
- LAYOUTGET(二)
- 第五周 项目一:三角形类(参数初始化表)
- opencv-形态学组合运算
- 对这几天服务器崩溃的小结
- 题目1066:字符串排序
- JMockit学习笔记(一,简介)
- oracle查看sql执行计划和统计信息