BZOJ 1216 操作系统(堆)
用堆模拟题目中的操作即可。
# 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 操作系统(堆)的更多相关文章
- BZOJ 1216: [HNOI2003]操作系统( 优先队列 )
按题意用priority_queue模拟即可 ---------------------------------------------------------------------- #inclu ...
- 【BZOJ 1216】 1216: [HNOI2003]操作系统 (模拟+优先队列)
1216: [HNOI2003]操作系统 Description 写一个程序来模拟操作系统的进程调度.假设该系统只有一个CPU,每一个进程的到达时间,执行时间和运行优先级都是已知的.其中运行优先级用自 ...
- BZOJ 1109: [POI2007]堆积木Klo
1109: [POI2007]堆积木Klo Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 948 Solved: 341[Submit][Statu ...
- BZOJ.1109.[POI2007]堆积木Klo(DP LIS)
BZOJ 二维\(DP\)显然.尝试换成一维,令\(f[i]\)表示,强制把\(i\)放到\(a_i\)位置去,现在能匹配的最多数目. 那么\(f[i]=\max\{f[j]\}+1\),其中\(j& ...
- BZOJ 4165 矩阵 堆
先把每个长为$mina$,宽为$minb$的矩阵扔到堆里,然后由于矩阵中的数都是正的,所以我们每取出来一个矩形,,就把他向四个方向扩张一行,再把这新的且更大的四个矩形扔到堆里.注意判重,于是我比较懒用 ...
- BZOJ 1233 干草堆 (单调队列优化DP)
$ BZOJ~1233~~ $ 干草堆: (题目特殊性质) $ solution: $ 很妙的一道题目,开始看了一眼觉得是个傻逼贪心,从后往前当前层能多短就多短,尽量节省花费.但是这是DP专题,怎么会 ...
- BZOJ 1078 斜堆
感谢MATO大神的博客 http://www.cppblog.com/MatoNo1/archive/2013/03/03/192131.html 注意细节. #include<iostream ...
- bzoj 1109 [POI2007]堆积木Klo(LIS)
[题意] n个数的序列,删除一个数后序列左移,求最后满足i==a[i]的最大个数. [思路] 设最终得到a[i]==i的序列为s,则s应满足: i<j,a[i]<a[j],i-a[i]&l ...
- BZOJ 1109 POI2007 堆积木Klo LIS
题目大意:给定一个序列,能够多次将某个位置的数删掉并将后面全部数向左串一位,要求操作后a[i]=i的数最多 首先我们如果最后a[i]=i的数的序列为S 那么S满足随着i递增,a[i]递增(相对位置不变 ...
随机推荐
- echarts 去掉上面的小图标
在option里找到toolbox,删除对应的代码即可: toolbox: { y : -30, show : true, feature : { mark : '辅助线开关', markUndo : ...
- 思维水题 poj1852
题目链接:http://poj.org/problem?id=1852 题意:木板长为n, 蚂蚁数量为k, 后面k个数,依次代表蚂蚁的位置, 当蚂蚁到达边界的时候会立马掉下,当两个蚂蚁相 ...
- High Water Mark 图示
+---- high water mark of newly created table | V +-------------------------------------------------- ...
- 成都Uber优步司机奖励政策(4月15日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 英特尔近日发布最新版实感™ SDK R5 (v7)
英特尔开发人员专区 原文地址 英特尔® 实感™ SDK 的 7.0.23.8048 版本(也称为 R5)现已推出.您将看到的主要变化包括: 支持英特尔® 实感™ SR300 摄像头:应于 2016 年 ...
- Liunx expect 基础
a script for study except #!/usr/bin/expect 声明文件内的语法使用 expect 的语法来执行. send send: 向进程发送字符串,用于模拟用户的输入. ...
- lxd&openstack-lxd源码剖析
lxd:https://linuxcontainers.org/lxd/,目标是融入到openstack体系被管理,像虚拟机一样被管理使用.从如下图可知,并非走的是libvirt-lxc路线,而是no ...
- JQuery 异步提交数据
类别添加 名称:   正在发送数据请求… <% dim strValue blnLogin = false; strValue = request.Form("t ...
- arcgis10.2怎么把地理坐标系转化为投影坐标系(平面,米制坐标) arcmap 10.2 从 WGS_1984 转 Beijing_1954
方法一:在Arcmap中转换:从 WGS_1984 转 Beijing_19541.加载要转换的数据,右下角为经纬度2.点击视图——数据框属性——坐标系统3.导入或选择正确的坐标系(如选:Beijin ...
- Base64编码图片存取与前台显示
需求:将Base64编码图片以BLOB类型存入数据库,需要时取出显示 后台: String base64str=new String(log.getRequest_imgdata());//log为实 ...