题意:有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笔试之字符逆序(一)

    将一个字符串str的内容颠倒过来,并输出.str的长度不超过100个字符. 如:输入“I am a student”,输出“tneduts a ma I”. package test; import ...

  2. JS 标签页切换

    一 <!DOCTYPE html><html><head><meta charset="utf-8"/><title>自 ...

  3. Android开发 Tablayout的学习

    前言 Tablayout一般做主页底下的导航栏开发或者上面的选择栏开发,就个人感觉Tablayout用于主页导航栏会比BottomNavigationView更好,自定义方面也更容易.缺点是没有动画也 ...

  4. Angular CLI ng常用指令整理

    一.组件创建 ng generate component heroes 二.运行项目 ng serve --open //--open 立即打开 三.创建指令 ng g directive my-ne ...

  5. H5在部分苹果手机IOS系统下重力感应无效

    原因不明,反正在IOS系统12.2以上的普通的H5移动端网页的重力感应功能无反应 解决方法: 把链接改为HTTPS,经过测试,12.2系统以上的如果你的链接是HTTP的,重力感应在网页上是没调起的,改 ...

  6. Android之TableLayout表格布局

    1.相关属性 1.1.常用属性 android:collapseColumns 设置需要被隐藏的列的序列号 android:shrinkColumns 设置允许被收缩的列的序列号 android:st ...

  7. spss-数据抽取-拆分与合并

    spss-数据抽取-拆分与合并 数据抽取也成为数据拆分,是指保留.抽取原数据表中某些字段.记录的部分信息,形成一个新字段.新纪录.分为:字段拆分和随机抽样两种方法. 一:字段拆分 如何提取" ...

  8. 设定计算属性setter

    <!DOCTYPE html> <html lang="zh"> <head> <title></title> < ...

  9. adb的安装及配置

    1.下载adb的安装包进行下载 2.将安装报进行解压 3.配置环境变量,将adb的根目录添加到path环境变量中 4.在终端命令行中输入adb  servion命令,检查是否安装成功,如显示版本号则安 ...

  10. redux在react项目中的应用

    今天想跟大家分享一下redux在react项目中的简单使用 1 1.redux使用相关的安装 yarn add redux yarn add react-redux(连接react和redux) 2. ...