题意:



思路:

贪心 能不覆盖的就不盖

写得很乱 左闭右开的 temp

//By SiriusRen
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,l,temp,ans;
struct Node{int from,to;}node[10050];
priority_queue<Node>pq;
bool operator < (Node a,Node b){
return a.from>b.from;
}
int main(){
scanf("%d%d",&n,&l);
for(int i=1;i<=n;i++){
scanf("%d%d",&node[i].from,&node[i].to),node[i].to--;
pq.push(node[i]);
}
while(!pq.empty()){
Node t=pq.top();pq.pop();
if(temp<=t.from){
int rec=(t.to-t.from+1)/l;
ans+=rec;
temp=t.from+l*rec;
if(temp<=t.to)ans++,temp+=l;
}
else if(temp>t.to)
{
continue;
}
else{
int rec=(t.to-temp+1)/l;
ans+=rec;temp+=l*rec;
if(temp<=t.to)ans++,temp+=l;
}
}
printf("%d\n",ans);
}

最新文章

  1. iOS--知识综合应用成就时髦小功能点
  2. 关于refs/for/ 和refs/heads/
  3. JS文件加载:比较async和DOM Script
  4. 14---Net基础加强
  5. ERROR 1442 (HY000):because it is already used by statement which invoked this stored function/tr
  6. Servlet &amp; JSP - Form-based Authentication
  7. Linux中_ALIGN宏背后的原理——内存对齐
  8. Python 学习开发笔记之IO操作
  9. PullToRefreshListView调用onRefreshComplete方法 无法取消刷新的bug
  10. 安卓handler.post问题
  11. idea maven 无法加载已经安装的模块
  12. android解决内存溢出的问题(没有从根本上解决)
  13. &#39;nmake&#39; 不是内部或外部命令,VCVARS32.BAT路径问题
  14. 《Python编程从入门到实践》_第五章_if语句
  15. C++ Primer 笔记——函数
  16. ResourceBundle与Properties读取配置文件
  17. 如何优雅地等待所有的goroutine退出
  18. python-opencv boundingRect使用注意
  19. 【转载】浅谈JavaScript,let和var定义变量的区别
  20. UOJ 347(洛谷4220) 【WC2018】通道——随机化

热门文章

  1. [HNOI2008]水平可见直线 单调栈
  2. 洛谷P2197 nim游戏模板
  3. 【Git 四】一款不错的 Git 客户端
  4. vue 退出动画无效解决方法
  5. iostat---监视磁盘CPU相关信息
  6. HDFS 断点续传,写文件功能
  7. WEB前端,混合排版,有的宽有的窄,滚动会出现空白处,怎么办。
  8. IOS &amp;#39;NSInternalInconsistencyException&amp;#39;
  9. Iocomp控件之数字显示【图文】
  10. Android Design Support Library(一)用TabLayout实现类似网易选项卡动态滑动效果