BZOJ 4425: [Nwerc2015]Assigning Workstations分配工作站
2024-10-20 06:40:17
难度在于读题
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
priority_queue<int,vector<int>,greater<int> > q;
struct node{
int l,r;
}e[1000005];
bool cmp(node a,node b){
return a.l<b.l;
}
int main(){
int n,m;
scanf("%d%d",&n,&m);
for (int i=1; i<=n; i++){
int x,y;
scanf("%d%d",&x,&y);
e[i]=(node){x,x+y};
}
sort(e+1,e+n+1,cmp);
q.push(e[1].r+m);
int ans=0;
for (int i=2; i<=n; i++){
while (!q.empty() && q.top()<e[i].l) q.pop();
if (!q.empty()){
int now=q.top();
if (e[i].l>=now-m){
ans++;
q.pop();
}
}
q.push(e[i].r+m);
}
printf("%d\n",ans);
return 0;
}
最新文章
- CJCMS系列---说说项目中的缓存实现(1)
- css 权重
- asp.net gridview动态添加列,并获取其数据;
- linux备忘
- SQL Server常用命令
- Google 面试题和详解
- ubuntu下简单的驱动编译
- HoloLens开发手记 - 开始使用Vuforia Getting started with Vuforia
- 机器学习 —— 类不平衡问题与SMOTE过采样算法
- ”dpkg: 处理归档 /var/cache/apt/archives/XXXXXX(--unpack)时出错“的解决方法
- Python中不尽如人意的断言Assertion
- HTTP与HTTPS有哪些区别?
- HanLP中人名识别分析
- [CocoaPods]入门
- nodejs中引用其他js文件中的函数
- python中的%s%是什么意思
- Andorid开发(二十二)——获取上下文getApplicationContext()、Activity.this、 getBaseContext
- python 开发学习
- OpenGL教程(25) skybox
- Thread 1 cannot allocate new log的问题分析 (转载)