SGU133 Border
来源:互联网 发布:网络跳线是什么 编辑:程序博客网 时间:2024/06/09 16:47
不知道为什么,之前都是while(scanf()!=EOF)可以,而这次就不行
解法:排序,维护r的最值即可...其实是不需要priority_queue的...
ps:刚把今天codeforces的题扫了一眼...然后就没有然后了...@_@ ,我太弱了...弱了...
#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm>#include<queue>using namespace std;struct seg{ int l,r;}s[16005];bool cmp(const seg &a,const seg &b){ return a.l<b.l;}int main(){ int n,i,ans; priority_queue<int,vector<int>,less<int> > q; scanf("%d",&n);// while(scanf("%d",&n)!=EOF)// { for(i=0;i<n;++i) { scanf("%d %d",&s[i].l,&s[i].r); } while(!q.empty()) q.pop(); ans=0; sort(s,s+n,cmp); q.push(s[0].r); for(i=1;i<n;++i) { if(q.top()>s[i].r) ans++; q.push(s[i].r); } cout<<ans<<endl;// printf("%d\n",ans);// } return 0;}
- SGU133 Border
- sgu133:Border
- SGU133 Border
- SGU133-Border (Sort)
- border
- Border
- border
- Border
- Border
- border
- border
- border
- border
- border
- border
- border
- border
- border
- 阿里巴巴2013实习招聘笔试题5月19日
- DataGridView DataGridViewCheckBoxColumn编辑时实时触发事件
- linux中的IO端口映射和IO内存映射
- oracle数据库归档模式浅析
- Graph and Queries hdu3762
- SGU133 Border
- 浅析人脸检测之Haar分类器方法
- 织梦 DeDeCMS 添加自定义属性的方法
- 将HTML5 Canvas的内容保存为图片
- javaScirpt事件监听
- 可以拖动排版可以关闭的DIV层
- 利用RSSLibJ读取RSS .
- Windows 7作PXE Server网络安装Ubuntu 10.04
- DedeCMS首页arclist分页arcpagelist标签实例解析