4425: [Nwerc2015]Assigning Workstations分配工作站
4425: [Nwerc2015]Assigning Workstations分配工作站
Description
Input
Output
Sample Input
3 5
1 5
6 3
14 6
Sample Input 2
5 10
2 6
1 2
17 7
3 9
15 6
Sample Output
2
Sample Output 2
3
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=;
#define p1 (p<<1)
#define p2 (p<<1|1)
struct node
{
int a,b;
}p[N];
int n,m,i,k,ans,t[N];
bool cmp(const node&x,const node&y)
{
return x.a<y.a;
}
void up(int p)
{
while((p>>)>)
{
if(t[p]<t[p>>])
{
swap(t[p],t[p>>]);
p>>=;
} else break;
}
}
void down(int p)
{
int x;
while(p1<=k)
{
if(p2<=k)
{
if(t[p1]<t[p2]) x=p1;else x=p2;
} else x=p1;
if(t[p]>t[x])
{
swap(t[p],t[x]);
p=x;
} else break;
}
}
int main()
{
scanf("%d%d",&n,&m);
for(i=;i<=n;i++)
scanf("%d%d",&p[i].a,&p[i].b);
sort(p+,p+n+,cmp);
k=;ans=;t[]=p[].a+p[].b+m;
for(i=;i<=n;i++)
{
while(k>&&t[]<p[i].a)
{
t[]=t[k--];
down();
}
if(t[]>=p[i].a&&t[]-m<=p[i].a)
{
ans++;
t[]=t[k--];
down();
}
t[++k]=p[i].a+p[i].b+m;
up(k);
}
cout<<ans;
return ;
}
4425: [Nwerc2015]Assigning Workstations分配工作站的更多相关文章
- BZOJ 4425: [Nwerc2015]Assigning Workstations分配工作站
难度在于读题 #include<cstdio> #include<algorithm> #include<queue> using namespace std; p ...
- 【bzoj4425】[Nwerc2015]Assigning Workstations分配工作站 贪心+堆
题目描述 佩内洛普是新建立的超级计算机的管理员中的一员. 她的工作是分配工作站给到这里来运行他们的计算研究任务的研究人员. 佩内洛普非常懒惰,不喜欢为到达的研究者们解锁机器. 她可以从在她的办公桌远程 ...
- 【贪心】【堆】Gym - 101485A - Assigning Workstations
题意:有n个人,依次来到机房,给你他们每个人的到达时间和使用时间,你给他们分配电脑,要么新开一台, 要么给他一台别人用完以后没关的.一台电脑会在停止使用M分钟后自动关闭.让你最大化不需要新开电脑的总人 ...
- Assigning Workstations
题目链接:http://vjudge.net/contest/127404#problem/A /* 给你n个数字,让你找出一个最小的数字,这个数字不在这些数字中出现的 ,注意:这个数字如果各个位上的 ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- word20161213
journal queue / 日志队列 journal quota / 日志配额 junction point / 交叉点 KDC, Key Distribution Center / 密钥分发中心 ...
- Gym101485: NWERC 2015(队内第6次训练)
A .Assigning Workstations 题意:给定N个人的工作时间和工作时长,我们可以假设有无数台工作机器,如果一台机器超过M时间未使用就会关闭,那么我们怎么安排机器的使用,使得需要开启机 ...
- 用route命令解决多出口的问题
网络已经走进了我们的生活.工作.学习之中,大多数单位.公司都已经连接到了Internet.但是,因为各种原因,有这样一个问题存在.就是:这些单位即有到公网(Internet)的出口连接,也有到专网(单 ...
- Five things that make Go fast-渣渣翻译-让GO语言更快的5个原因
原文地址:https://dave.cheney.net/2014/06/07/five-things-that-make-go-fast 翻译放在每个小段下面 Anthony Starks has ...
随机推荐
- CSS3 动画实现方法大全
常用效果总结(需要引用animate.css) <!doctype html> <html lang="en"> <head> <meta ...
- js中的document.ready
1.概念 表示在dom结构绘制完成后执行,可能DOM元素关联的部分并未加载完 2.写法 $(document).on("ready",function(){ }) $(docume ...
- perl发送post数据
把post数据写进一个匿名数组里就行 #!/usr/bin/env perl -w use strict; use LWP::UserAgent; my $ua = LWP::UserAgent-&g ...
- [转载]循规蹈矩:快速读懂SQL执行计划的套路与工具
作者介绍 梁敬彬,福富研究院副理事长.公司唯一四星级内训师,国内一线知名数据库专家,在数据库优化和培训领域有着丰富的经验.多次应邀担任国内外数据库大会的演讲嘉宾,在业界有着广泛的影响力.著有多本畅销书 ...
- C中级 数据序列化简单使用和讨论 (二)
引言 - 一种更好的方式 其实不管什么语言, 开发框架都会遇到序列化问题. 序列化可以理解为A 和 B 交互的一种协议. 很久以前利用 printf 和 scanf 的协议实现过一套序列化问题. C ...
- 设计模式之笔记--抽象工厂模式(Abstract Factory)
抽象工厂模式(Abstract Factory) 定义 抽象工厂模式(Abstract Factory),提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类. 类图 描述 多个抽象产品 ...
- win7下安装 LINUX虚拟机
文件名: VMware-workstation-full-10.0.6-2700073.exe 百度云共享链接: pan.baidu.com/s/1o6McGmI VMware workstation ...
- php文件上传错误信息
错误信息说明 UPLOAD_ERR_OK:其值为0,没有错误发生,文件上传成功 UPLOAD_ERR_INI_SIZE:其值为1,上传的文件超过了php.ini和upload_max_filesize ...
- CCF试题:高速公路(Targin)
问题描述 某国有n个城市,为了使得城市间的交通更便利,该国国王打算在城市之间修一些高速公路,由于经费限制,国王打算第一阶段先在部分城市之间修一些单向的高速公路. 现在,大臣们帮国王拟了一个修高速公路的 ...
- 初次接触express
今天初次使用express,还是写写心得好了. 中间件 mothod nodemon ~的使用 中间件 中间件我觉得就是个开箱即用的工具,写好中间件函数,直接use就好. 示例1: let myLog ...