poj1828
2011-10-17 20:44
295 查看
找动态规划的题,却找到这道,动态规划该怎么做不知道,只会结构体二级排序。。。
#include <iostream> #include <algorithm> using namespace std; #define N 50002 struct Position { int x, y; } monkey ; 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; }
相关文章推荐
- POJ - 1177/HDU - 1828 Picture(线段树-矩形并周长)
- POJ 1177 Pictures(HDU 1828) (线段树+离散化+线段扫描)
- poj 1828 Monkeys' Pride 模拟
- hdu 1828(poj 1177)Picture(线段树+扫描线)(轮廓线)
- poj 1177 && hdu 1828
- hdu 1828 / poj/pku 1177(Picture)(线段树求矩形覆盖面周长)
- hdu 1828 poj 1177 picture 求周长并
- hdu 1828(poj 1177)Picture(线段树+扫描线)(轮廓线)
- poj1828
- POJ 1828 选猴王 排序qsort应用
- poj 1177 / hdu 1828 线段树 离散化 扫描线
- hdu 1828、poj1177求矩形周长并 线段树 扫描线
- hdu 1828(poj 1177)Picture(线段树+扫描线)(轮廓线)
- POJ 1828 Monkeys' Pride 笔记
- POJ 1828 Monkeys' Pride
- POJ 1828 Monkeys' Pride
- poj 1828 Monkeys' Pride
- 【扫描线法】&& poj 1177 && hdu 1828
- POJ 1177&&HDU1828 Picture 线段树+扫描线
- poj 1828 Monkeys' Pride