题意:有n个任务,每个任务有三个参数ri,di和wi,表示必须在时刻[ri,di]之内执行,工作量为wi。处理器执行速度可以变化,当执行速度为s时,工作量为wi。处理器的速度可以变化,当执行速度为s时,一个工作量为wi的任务需要执行wi/s个单位时间。任务不一定连续执行,可以分成若干块。求出处理器执行过程中最大速度的最小值。
 
首先按照左端点排序,然后二分答案,对于每一刻时间贪心地选当前未结束的任务中右端点最小的那个。
//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的更多相关文章

  1. 【一坨理论AC的题】Orz sxy大佬

    1.UVA10891 Game of Sum 2.LA4254 Processor . 3.UVA10905 Children's Game 4.UVA11389 The Bus Driver Pro ...

  2. 反射动态创建不同的Processor

    1. 定义抽象方法 public abstract class BaseProcesser    {        public abstract void GetCustomerReportCard ...

  3. processor, memory, I/O

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION 3.3 INTERCONNECTION S ...

  4. 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 ...

  5. instruction-set architecture Processor Architecture

    Computer Systems A Programmer's Perspective Second Edition We have seen that a processor must execut ...

  6. 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 ...

  7. Processor Speculative & pipeline

    https://en.wikipedia.org/wiki/Instruction-level_parallelism https://en.wikipedia.org/wiki/Instructio ...

  8. 深入学习Heritrix---解析处理器(Processor)(转)

    深入学习Heritrix---解析处理器(Processor) 本节解析与处理器有关的内容. 与处理器有关的主要在以下几个类:Processor(处理器类),ProcessorChain(处理器类), ...

  9. Heritrix源码分析(八) Heritrix8个处理器(Processor)介绍(转)

    本博客属原创文章,欢迎转载!转载请务必注明出处:http://guoyunsky.iteye.com/blog/643367       本博客已迁移到本人独立博客: http://www.yun5u ...

随机推荐

  1. java笔试之参数解析(正则匹配)

    在命令行输入如下命令: xcopy /s c:\ d:\, 各个参数如下: 参数1:命令字xcopy 参数2:字符串/s 参数3:字符串c:\ 参数4: 字符串d:\ 请编写一个参数解析程序,实现将命 ...

  2. 属性面板:tabcontroller

    Tabcontroller 布局 Anchor 设置控件距离选定方向固定: Dock 定义要绑定到容器的控件边框 Location 设置控件对于容器左上角的坐标 Margin 指定此控件与另一控件边距 ...

  3. linux nload命令简介及安装方法

    第一步:nload命令简介 nload 命令用于查看linux网络流量状况,实时输出.可以理解为是一个控制台应用程序,用来实时监测网络流量和带宽使用情况的命令. 使用可视化的界面显示流入和留出系统的网 ...

  4. 乌云精华漏洞整合(epub)

    还是7月份的 链接: http://pan.baidu.com/s/1kUGIOez 密码: gfqp

  5. thinkphp 子查询

    从3.0版本开始新增了子查询支持,有两种使用方式: 大理石平台检验标准 1.使用select方法 当select方法的参数为false的时候,表示不进行查询只是返回构建SQL,例如: // 首先构造子 ...

  6. c语言学习笔记 - 文件操作

    #include <stdio.h>#include <time.h> int main(void){ time_t t;               //类似于size_t那 ...

  7. 移动端自定义键盘的vue组件 ----keyboard

    <style scoped lang="less"> .keyboard { /* height: 250px; */ width: 100%; position: f ...

  8. windows 可执行文件分析

    windows可执行文件是什么? 是具有PE文件格特性的文件,例如:.exe.dll.ocx等文件. 注:(这里只是让大家能明了一些,其实,可执行与否,和后缀没有什么关系,后缀只是windows方便管 ...

  9. work-shineyoo:杂项1906

    ylbtech-work-shineyoo:杂项1906 1.返回顶部 1. 1.1 SMS (手机的)短信服务.Short Message Service. 1.2 VOD 视频点播.Video o ...

  10. Python数据挖掘之决策树DTC数据分析及鸢尾数据集分析

    Python数据挖掘之决策树DTC数据分析及鸢尾数据集分析 今天主要讲述的内容是关于决策树的知识,主要包括以下内容:1.分类及决策树算法介绍2.鸢尾花卉数据集介绍3.决策树实现鸢尾数据集分析.希望这篇 ...