LA 4254 二分
来源:互联网 发布:for循环遍历json 编辑:程序博客网 时间:2024/05/18 02:49
#include<cstdio>#include<cstring>#include<queue>#include<algorithm>#define INF 0x3f3f3f3f#define MAX(x,y) ((x)>(y)?(x):(y))#define MIN(x,y) ((x)>(y)?(y):(x))using namespace std;struct node{int l,r,w;}d[100100];int L,R,n;bool operator<(node a,node b){return a.r>b.r;}bool cmp(const node &a,const node &b){return a.l<b.l;}int ok(int v){int tot=0; priority_queue<node>q; for(int i=L;i<=R;i++) { int tem=v; while(tot!=n&&d[tot].l<i) q.push(d[tot++]); while(!q.empty()&&tem!=0) { node u=q.top(); q.pop(); if(u.r<i) return 0; if(u.w>tem) { u.w-=tem; tem=0; q.push(u); } else tem-=u.w; } } if(!q.empty()) return 0; else return 1;}int main(){int T ;scanf("%d",&T);while(T--){int l=1,r=0;scanf("%d",&n);R=0;L=INF;for(int i=0;i<n;i++){scanf("%d%d%d",&d[i].l,&d[i].r,&d[i].w);R=MAX(R,d[i].r);L=MIN(L,d[i].l);r+=d[i].w;}sort(d,d+n,cmp);while(l<r){int m=(l+r)>>1;if(ok(m))r=m;elsel=m+1;}printf("%d\n",l);}}
阅读全文
0 0
- LA 4254 二分
- LA 4254 Processor 贪心+二分 *
- LA 4254 Processor(二分+贪心+优先队列)
- LA 4254 Processor (单调队列 + 二分)
- LA 3971 Assemble / 二分
- LA 3971 二分
- LA 3635 - Pie 【二分】
- LA 3635 Pie (二分)
- LA 4725 Airport 二分 -
- LA-3211-TwoSAT,二分
- LA 4253 Archery (二分)
- LA 3177 Beijing Guards 二分 -
- 二分(派,LA 3635)
- LA 4725 Airport (二分答案)
- LA 3177 长城守卫(推理+二分)
- AsiaHatyai-2012 & LA 6144 - Radiation 二分搜索
- LA - 4513 - Stammering Aliens(Hash + 二分)
- UVA LA 3971-(Assemble)二分答案
- nginx常用配置
- JavaScript_函数
- JUnit
- 关于静默安装和安装后自启动
- RobotFramework之Dialogs
- LA 4254 二分
- 机器学习聚类算法
- 有名的面试题 有一个二维数组(n*n)
- 按照SCN 闪回数据库!!ORA-38754: FLASHBACK DATABASE not started; required redo log is not available
- 1.jdk认识及使用
- SpringBoot:使用spring-boot-devtools进行热部署
- unity 人物IK设置 与乒乓函数
- 科技圈大佬童年照_你认识几张?
- 传址调用