用堆模拟题目中的操作即可。

# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-
# define MOD
# define INF
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<,l,mid
# define rch p<<|,mid+,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
void Out(int a) {
if(a<) {putchar('-'); a=-a;}
if(a>=) Out(a/);
putchar(a%+'');
}
const int N=;
//Code begin... struct node{
int id, to, t, now, level;
node(int _id=, int _to=, int _t=, int _level=):id(_id),to(_to),t(_t),level(_level){}
bool operator <(const node&r)const{
if (level!=r.level) return level<r.level;
return to>r.to;
}
};
priority_queue<node>que; int main ()
{
node tmp;
int id, to, t, level, f=;
while (~scanf("%d%d%d%d",&id,&to,&t,&level)) {
while (!que.empty()) {
tmp=que.top(); que.pop();
if (tmp.t<=to-f) f+=tmp.t, printf("%d %d\n",tmp.id,f);
else {tmp.t-=(to-f); que.push(tmp); break;}
}
f=to;
que.push(node(id,to,t,level));
}
while (!que.empty()) {
tmp=que.top(); que.pop();
f+=tmp.t;
printf("%d %d\n",tmp.id,f);
}
return ;
}

BZOJ 1216 操作系统(堆)的更多相关文章

  1. BZOJ 1216: [HNOI2003]操作系统( 优先队列 )

    按题意用priority_queue模拟即可 ---------------------------------------------------------------------- #inclu ...

  2. 【BZOJ 1216】 1216: [HNOI2003]操作系统 (模拟+优先队列)

    1216: [HNOI2003]操作系统 Description 写一个程序来模拟操作系统的进程调度.假设该系统只有一个CPU,每一个进程的到达时间,执行时间和运行优先级都是已知的.其中运行优先级用自 ...

  3. BZOJ 1109: [POI2007]堆积木Klo

    1109: [POI2007]堆积木Klo Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 948  Solved: 341[Submit][Statu ...

  4. BZOJ.1109.[POI2007]堆积木Klo(DP LIS)

    BZOJ 二维\(DP\)显然.尝试换成一维,令\(f[i]\)表示,强制把\(i\)放到\(a_i\)位置去,现在能匹配的最多数目. 那么\(f[i]=\max\{f[j]\}+1\),其中\(j& ...

  5. BZOJ 4165 矩阵 堆

    先把每个长为$mina$,宽为$minb$的矩阵扔到堆里,然后由于矩阵中的数都是正的,所以我们每取出来一个矩形,,就把他向四个方向扩张一行,再把这新的且更大的四个矩形扔到堆里.注意判重,于是我比较懒用 ...

  6. BZOJ 1233 干草堆 (单调队列优化DP)

    $ BZOJ~1233~~ $ 干草堆: (题目特殊性质) $ solution: $ 很妙的一道题目,开始看了一眼觉得是个傻逼贪心,从后往前当前层能多短就多短,尽量节省花费.但是这是DP专题,怎么会 ...

  7. BZOJ 1078 斜堆

    感谢MATO大神的博客 http://www.cppblog.com/MatoNo1/archive/2013/03/03/192131.html 注意细节. #include<iostream ...

  8. bzoj 1109 [POI2007]堆积木Klo(LIS)

    [题意] n个数的序列,删除一个数后序列左移,求最后满足i==a[i]的最大个数. [思路] 设最终得到a[i]==i的序列为s,则s应满足: i<j,a[i]<a[j],i-a[i]&l ...

  9. BZOJ 1109 POI2007 堆积木Klo LIS

    题目大意:给定一个序列,能够多次将某个位置的数删掉并将后面全部数向左串一位,要求操作后a[i]=i的数最多 首先我们如果最后a[i]=i的数的序列为S 那么S满足随着i递增,a[i]递增(相对位置不变 ...

随机推荐

  1. odoo学习之:【转】控制menuitem的显示权限

    作者原文:https://blog.csdn.net/wangnan537/article/details/43992771 在实际应用Odoo(OpenERP)的过程中, 会有对某用户组隐藏菜单的需 ...

  2. runtime如何实现weak属性

    首先了解weak是一种非拥有关系,属性所值对象销毁时,属性值会清空(nil). Runtime对注册的类会进行布局,对于weak对象会放入hash表中,用weak指向的内存地址作为key,当对象引用计 ...

  3. Migrating to WebSphere 9

    Migrating to WebSphere 9 Make a migration plan Requirements Migrate WebSphere profiles into the new ...

  4. 如何使用Win+R快捷键打开自定义程序

    鉴于大家对于提高效率这块有争议,更改了下标题. 大家平时一定都使用过Win+R运行快捷键, 在运行里可以快捷的打开一些系统软件,比如说输入mstsc是打开远程连接,输入explorer是打开文件管理器 ...

  5. 001 -js对时间日期的排序

    001-JS对时间日期的排序 最近在做公司的项目时间,产品给了一个很简单的页面,让帮忙写一下.首先看一下产品的需求: 需要对该列表进行排序 思路:(1)可以在数据库写sql语句的时间直接一个DESC按 ...

  6. 【MySQL 数据库】MySQL目录

    目录 [第一章]MySQL数据概述 [第二章]MySQL数据库基于Centos7.3-部署 [MySQL解惑笔记]Centos7下卸载彻底MySQL数据库 [MySQL解惑笔记]忘记MySQL数据库密 ...

  7. vps搭建个人网盘不二之选—kodexplorer介绍,包含安装步骤

    之前给大家介绍过seafile.h5ai等网盘系统,今天给大家介绍下kodexplorer网盘系统.Kodexplorer,也叫芒果云.可道云.kodcloud,总之名字改了不少.但其本身作为一个网盘 ...

  8. 福利,一张图看懂IT售前工程师修炼之道

    职场中的新人如何自我定位? 如何深刻理解IT售前这个职位? 如何从IT售前菜鸟成长为IT售前专家? 推荐这本书<IT售前工程师修炼之道> 本书精华内容 售前的重要性 售前要有逻辑能力 售前 ...

  9. 马士兵老师hadoop讲解总结博客地址记录(啊啊啊啊啊,自己没有保存写好的博客...)

    http://www.cnblogs.com/yucongblog/p/6650822.html

  10. HDU 5167 Fibonacci 筛法+乱搞

    题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5167 题意: 给你一个x,判断x能不能由斐波那契数列中的数相乘得到(一个数可以重复使用) ...