HDU2037
来源:互联网 发布:怎么安装linux虚拟机 编辑:程序博客网 时间:2024/06/06 02:59
思路:贪心,对于结构体排序,从结束时间小到大的顺序
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 105;int n, cnt;struct state{ int start, end;}s[N];bool cmp(const state& a, const state& b) { return a.end < b.end;}int main() { while (scanf("%d", &n) && n) { cnt = 0; for (int i = 0; i < n; i++) scanf("%d %d", &s[i].start, &s[i].end); sort(s, s + n, cmp); int t = -1; for (int i = 0; i < n; i++) { if (s[i].start >= t) { t = s[i].end; cnt++; } } printf("%d\n", cnt); } return 0;}
0 0
- hdu2037
- hdu2037
- hdu2037
- HDU2037
- hdu2037
- HDU2037
- HDU2037
- hdu2037
- HDU2037
- HDU2037
- hdu2037
- HDU2037(贪心)
- hdu2037贪心
- 贪心-----HDU2037
- 贪心 hdu2037
- HDU2037--贪心入门
- HDU2037------贪心加冒泡
- HDU2037小技巧
- POJ 1637 混合图欧拉回路
- 九种方法帮你越挫越勇
- android对象序列化
- Cocos2d-x SQLite
- MTK Android Driver :key
- HDU2037
- 小数在计算机的表示
- Android 手势识别
- Oracle—同义词
- 离合器的操作技巧
- 应用处理器 微架构2013版
- Pat(Advanced Level)Practice--1020(Tree Traversals)
- 线段树区间更新poj3468
- ubuntu中视频播放器、音乐播放器安装