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 ...
随机推荐
- Linux定时重启
1.安装crontabyum install cixie-cron yum install crontabs 2.编辑cron第一步,登陆账号第二步,输入crontab -e第三步,输入i ...
- PostgreSQL问题解决--连接数过多
I am trying to connect to a Postgresql database, I am getting the following Error: Error:org.postgre ...
- 廖雪峰Java11多线程编程-4线程工具类-1ThreadLocal
多线程是Java实现多任务的基础: Thread ExecutorService ScheduledThreadPool Fork/Join Thread对象代表一个线程:调用Tread.curren ...
- 【转帖】WebRTC回声抵消模块简要分析
webrtc 的回声抵消(aec.aecm)算法主要包括以下几个重要模块:回声时延估计:NLMS(归一化最小均方自适应算法):NLP(非线性滤波):CNG(舒适噪声产生).一般经典aec算法还应包括双 ...
- 有关阿里云对SaaS行业的思考,看这一篇就够了
过去二十年,随着改革开放的深化,以及中国的人口红利等因素,中国诞生了大批To C的高市值互联网巨头,2C的领域高速发展,而2B领域一直不温不火.近两年来,在C端流量饱和,B端数字化转型来临的背景下,中 ...
- HTML和css简单日常总结
今天主要学习了两个部分:第一部分html:在w3school学习了一些标签的使用和一些属性和方法,例如一些标签<a>,<h1><h6><from>< ...
- Python(三)基础篇之「模块&面向对象编程」
[笔记]Python(三)基础篇之「模块&面向对象编程」 2016-12-07 ZOE 编程之魅 Python Notes: ★ 如果你是第一次阅读,推荐先浏览:[重要公告]文章更新. ...
- Django之模板语言(一)
1.Django的模板语言(简而言之,字符串替换) 1.目前为止已经学过的模板语言: 1.{{ name }} ------>变量 2. for 循环: {% for i in book_li ...
- 【机器学习】机器学习入门02 - 数据拆分与测试&算法评价与调整
0. 前情回顾 上一周的文章中,我们通过kNN算法了解了机器学习的一些基本概念.我们自己实现了简单的kNN算法,体会了其过程.这一周,让我们继续机器学习的探索. 1. 数据集的拆分 上次的kNN算法介 ...
- HBase功能组件