杭电HDUacm2037
来源:互联网 发布:怎么成为起点网络作家 编辑:程序博客网 时间:2024/06/05 09:20
贪心算法,同类于看电视的还有老鼠拿钱和猫换食物。
#include <stdio.h>#include <algorithm>using namespace std;struct time {int s;int e;bool operator < (const time &A) const {return e < A.e;}}buf[101];int main() {int n, i, ans, currentTime;while(scanf("%d", &n) != EOF) {if(n==0)break;for(i=0; i<n; i++) {scanf("%d%d", &buf[i].s, &buf[i].e);}ans = 0;currentTime = 0;sort(buf, buf+n);for(i=0; i<n; i++) {if(currentTime<=buf[i].s) {currentTime = buf[i].e;ans ++;}}printf("%d\n", ans);}return 0;}
0 0
- 杭电HDUacm2037
- 杭电
- 杭电
- 杭电
- 杭电 1234 和 杭电 2115
- 杭电2056之Rectangles 杭电
- 杭电ACM1061Rightmost Digit
- 杭电2099 7.11
- 杭电ACM 1003
- 杭电 ACM 2016
- 杭电ACM1466
- 杭电ACM1003
- 杭电ACM1225
- 杭电ACM2023
- 杭电ACM2602
- 杭电ACM2955
- 杭电ACM3198
- 杭电ACM2028 求教
- C#特性本质
- swift UI专项训练16 ProgressView进度条
- SQL Server乐观锁定和悲观锁定实例
- Groovy入门教程
- 手机共享电脑Wifi软件网络抓包
- 杭电HDUacm2037
- Linux下的经典软件-史上最全
- 编译并测试 android goldfish kernel x86
- Thinking in Java学习笔记,使用Exchanger交换资源
- 【Python】闭包中一个不易察觉的陷阱
- 和安全有关的那些事(非对称加密、数字摘要、数字签名、数字证书、SSL、HTTPS及其他)
- MySQL逻辑架构
- 1569选夫婿
- Android Studio更新升级方法