【NOIP考前题目回顾】Luogu P1047
来源:互联网 发布:怎么在官网下载mysql 编辑:程序博客网 时间:2024/06/05 20:13
思路
类似前缀和,维护一下差分就好。
代码
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;int a[10005],n,m,ans=0;int main(){ scanf("%d%d",&n,&m); for (int i=1;i<=m;i++) { int x,y; scanf("%d%d",&x,&y); a[x]++,a[y+1]--; } ans=(a[0]==0); for (int i=1;i<=n;i++) { a[i]+=a[i-1]; if (a[i]==0) ans++; } cout<<ans; return 0;}
阅读全文
0 0
- 【NOIP考前题目回顾】Luogu P1047
- 【NOIP考前题目回顾】Luogu P1000
- 【NOIP考前题目回顾】Luogu P1001
- 【NOIP考前题目回顾】Luogu P1003
- 【NOIP考前题目回顾】Luogu P1005
- 【NOIP考前题目回顾】Luogu P1006
- 【NOIP考前题目回顾】Luogu P1005
- 【NOIP考前题目回顾】Luogu P1012
- 【NOIP考前题目回顾】Luogu P1040
- 【NOIP考前题目回顾】Luogu P1046
- Luogu考前模拟Round2总结
- NOIP 考前模板整理
- NOIP 考前注意
- NOIP考前的心得体会
- NOIP 考前错误总结
- NOIP考前总结
- noip考前大总结
- NOIP 考前提醒
- 前端面试之前要准备的那些事
- 深度分析游戏中的随机概率
- LSP快速扩散
- Boost.Asio 异步执行方法,post()\dispach()\wrap().
- React Native学习笔记二之写个Hello World
- 【NOIP考前题目回顾】Luogu P1047
- MySQL索引:聚簇索引与非聚簇索引的区别
- Ipython:交互式的Python命令行
- 调用图灵机器人接口进行聊天
- [RK3288][Android6.0] 不同分辨率的bootanimation.zip下载
- 如何上传jar包至Maven私服
- CSS选取第几个标签元素:nth-child、first-child、last-child
- 百度地图接口(输入地址获取经纬度)
- 字节流与字符流区别