poj1828
来源:互联网 发布:深度系统优化工具 编辑:程序博客网 时间:2024/05/22 09:47
找动态规划的题,却找到这道,动态规划该怎么做不知道,只会结构体二级排序。。。
#include <iostream>#include <algorithm>using namespace std;#define N 50002struct Position{int x, y;} monkey[N];bool compare(const Position &a, const Position &b){if(a.x != b.x)return a.x > b.x;else return a.y > b.y;}int main(){int n, i, cnt, tmp;while(scanf("%d", &n) && n){for(i = 0; i < n; i++)scanf("%d%d", &monkey[i].x, &monkey[i].y);sort(monkey, monkey+n, compare);cnt = 1;tmp = monkey[0].y;for(i = 1; i < n; i++){if(monkey[i].y > tmp){cnt++;tmp = monkey[i].y;}}printf("%d\n", cnt);}return 0;}
- poj1828
- poj1828
- poj1828-Monkeys' Pride
- poj1828 Monkeys' Pride
- 0.9poj1828(排序挺好的题)
- 会员管理系统
- 英文VS2010安装中文版MSDN文档方法
- poj 1466 Girls and Boys (二分图最大独立集)
- TCP三次握手/四次挥手详解
- dom.loadXML() -- IE&FF 兼容问题(原文:http://www.ie0595.com/news/read.asp?id=152)
- poj1828
- 2011-10-17 sverlet的应用
- DoWhile0--华硕笔试题
- unix环境高级编程-3.10-文件共享
- 新概念英语 Lesson 19
- Hibernate性能优化
- 什么是数据验证
- 关于使用BASE64编码后的问题
- iphone ios 字符串NSString格式化format输出