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 ...
随机推荐
- javaweb中静态文件的处理方法
方案一:激活Tomcat的defaultServlet来处理静态文件 在web.xml中添加: <servlet-mapping> <servlet-name>default& ...
- 基于Swagger+SpringBoot快速构建javaweb项目
章节导航 SpringBoot&Swagger简介 数据模型和接口定义 项目框架生成 业务逻辑实现 项目源码地址 github项目路径:https://github.com/Vikezhu/s ...
- 使用Cookie实现显示用户上次访问时间
一. 常用Cookie API介绍 1. 获取cookie request.getCookies(); // 返回Cookie[] 2. 创建cookie Cookie(String key, St ...
- codevs1222 信与信封的问题
二分图匹配. 先匹配一次,一定是完美匹配.然后枚举每条边,去掉它,若是不能完美匹配,这条边就必须. #include<cstdio> #include<cstring> #in ...
- 用Spire.PDF提取PDF里的PNG图片
用Nuget抓取类库,FreeSpire.PDF就可以 代码如下 , 亲测可以抓取PNG图形,即使原图是JPG,也会存成PNG格式输出: //加载PDF文档 PdfDocument doc = new ...
- JS 日期比较
Js 日期比较方法 第一种方式 function compareDate(s1,s2){ return ((new Date(s1.replace(/-/g,"\/")))> ...
- 2019-2-26-SublimeText-快速打开当前文件的文件夹
title author date CreateTime categories SublimeText 快速打开当前文件的文件夹 lindexi 2019-02-26 18:45:29 +0800 2 ...
- Leetcode515. Find Largest Value in Each Tree Row在每个树行中找最大值
您需要在二叉树的每一行中找到最大的值. 示例: 输入: 1 / \ 3 2 / \ \ 5 3 9 输出: [1, 3, 9] class Solution { public: vector<i ...
- 图解nginx配置文件nginx.conf
1. 一个server表示一个虚拟主机, 说白了就是网站, 一个nginx可以有多个server 2. listen网站监听的端口 3. server_name网站的域名 4. root是网站的相对目 ...
- 第一章 使用开发者模式快速入门 Odoo 12
本文为最好用的免费ERP系统Odoo 12开发手册系列文章第一篇. Odoo提供了一个快速应用开发框架,非常适合创建商业应用.这类应用通常用于保留业务记录,增删改查操作.Odoo 不仅简化了这类应用的 ...