LA4254 Processor
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<set>
using namespace std;
const int maxn=1e4+10;
int T,n; int aa;char cc;
int read() {
aa=0;cc=getchar();
while(cc<'0'||cc>'9') cc=getchar();
while(cc>='0'&&cc<='9') aa=aa*10+cc-'0',cc=getchar();
return aa;
} struct Node{
int l,r,w;
}node[maxn]; bool cmp(const Node& x,const Node& y) {
return x.l==y.l? x.r<y.r:x.l<y.l;
} struct Pp{
int noww,r;
bool operator < (const Pp& b) const{return r<b.r;}
}; multiset<Pp> G;
multiset<Pp>::iterator it;
bool check(int s) {
G.clear();
int pos=1,time=node[1].l,x,y,ss;
for(;;time++) {
if(pos>n&&G.empty()) return 1; ss=s;
while(ss>0&&!G.empty()) {
it=G.begin(); x=it->noww; y=it->r;
if(y<time) return 0; G.erase(it);
if(x>ss) G.insert(Pp{x-ss,y});
ss-=x;
}
while(node[pos].l==time&&pos<=n)
G.insert(Pp{node[pos].w,node[pos].r}),pos++;
}
if(G.empty()) return 1;
return 0;
} int main() {
T=read();
while(T--) {
memset(node,0,sizeof(node));
n=read();int l=0,r=0;
for(int i=1;i<=n;++i) {
node[i].l=read();
node[i].r=read();
node[i].w=read();
// l=max(l,(node[i].w-1)/(node[i].r-node[i].l+1));
r+=node[i].w;
}
sort(node+1,node+n+1,cmp);
while(l<r-1) {
if(!l) l++;
int mid=(l+r)>>1;
if(check(mid)) r=mid;
else l=mid;
}
printf("%d\n",r);
}
return 0;
}
/*
1
8
1 6 16
3 5 12
8 15 33
11 14 14
15 18 10
16 19 12
20 24 16
22 25 10
*/
LA4254 Processor的更多相关文章
- 【一坨理论AC的题】Orz sxy大佬
1.UVA10891 Game of Sum 2.LA4254 Processor . 3.UVA10905 Children's Game 4.UVA11389 The Bus Driver Pro ...
- 反射动态创建不同的Processor
1. 定义抽象方法 public abstract class BaseProcesser { public abstract void GetCustomerReportCard ...
- processor, memory, I/O
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION 3.3 INTERCONNECTION S ...
- improve performance whilemaintaining the functionality of a simpler and more abstract model design of processor hardware
Computer Systems A Programmer's Perspective Second Edition In this chapter, we take a brief look at ...
- instruction-set architecture Processor Architecture
Computer Systems A Programmer's Perspective Second Edition We have seen that a processor must execut ...
- simplify the design of the hardware forming the interface between the processor and thememory system
Computer Systems A Programmer's Perspective Second Edition Many computer systems place restrictions ...
- Processor Speculative & pipeline
https://en.wikipedia.org/wiki/Instruction-level_parallelism https://en.wikipedia.org/wiki/Instructio ...
- 深入学习Heritrix---解析处理器(Processor)(转)
深入学习Heritrix---解析处理器(Processor) 本节解析与处理器有关的内容. 与处理器有关的主要在以下几个类:Processor(处理器类),ProcessorChain(处理器类), ...
- Heritrix源码分析(八) Heritrix8个处理器(Processor)介绍(转)
本博客属原创文章,欢迎转载!转载请务必注明出处:http://guoyunsky.iteye.com/blog/643367 本博客已迁移到本人独立博客: http://www.yun5u ...
随机推荐
- 【案例】鼠标按下,DIV跟随移动
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 基本包装类型Boolean、Number、String特性及常用方法
基本包装类型:Boolean.Number.String 一.String 字符串常用方法 1.indexOf() lastIndexOf() 返回相应字符的索引号 2.slice(index1, ...
- gulp 前端构建工具使用
gulp 前端构建工具使用 1.新建一个web h5项目 2.准备好gulpfile.js文件 (1)下载链接:https://pan.baidu.com/s/116J-BaYOMRzeJW3i_J ...
- Ubuntu下安装和配置Apache2,小编觉得挺不错的,现在就分享给大家
本篇文章主要介绍了详解Ubuntu下安装和配置Apache2,小编觉得挺不错的,现在就分享给大家,也给大家做个参考.有兴趣的朋友可以了解一下.(http://xz.8682222.com) 在Ubun ...
- poj3167- Cow Patterns
传送门 两个串相等定义为串中每一位排序后的相对大小相等. 一位相等等价于这一位前面比他小的和等于他的数的个数相等. 那么用kmp,比较的时候比较这两个个数就可以了. 一开始很瓜地想,询问一段区间内比我 ...
- form表单简易注册登陆
注册页面: html <form action="updata.php" method="post" id="text_form"&g ...
- 笔试中sizeof求字节数的问题
1. ]) { cout<<sizeof(ch)<<endl; //或者sizeof(ch)=?; } 这种情况,数组名作为形参,退化成指针,所以sizeof结果是4(32位编 ...
- Python学习day39-并发编程(各种锁)
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- Django项目: 3.用户注册功能
本章内容的补充知识点 导入库的良好顺序: 1.系统库 2.django库 3.自己定义的库(第三方库) redis缓存数据库的数据调用速度快,但是不利于长时间保存. mysql用于长时间存储,但是调用 ...
- eclipse下项目复制改名注意事项
当在Eclipse下复制Web工程时 1.需要修改复制后新工程源码文件下 .settings 文件夹下的org.eclipse.wst.common.component中的内容为本工程名,明细如图: