hdu1051 Wooden Sticks
生活随笔
收集整理的這篇文章主要介紹了
hdu1051 Wooden Sticks
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目:http://acm.hdu.edu.cn/showproblem.php?pid=1051
大意:求最少升序序列的個數。
?
#include <cstdio> #include <cstring> #include <algorithm> #define N 5000 + 5 using namespace std; struct node {int x, y;bool operator < (const node& t) const {return (x < t.x) || (x == t.x && y < t.y);} } f[N]; bool mark[N]; int main() {int T, n, tw, ans, i, j;scanf("%d", &T);while (T--) {scanf("%d", &n);for (i = 0; i < n; i++) scanf("%d%d", &f[i].x, &f[i].y);sort(f, f + n);memset(mark, false, sizeof(mark));ans = 0;for (i = 0; i < n; i++)if (!mark[i]) {tw = f[i].y;mark[i] = true;ans++;for (j = i + 1; j < n; j++)if (!mark[j] && f[j].y >= tw) {tw = f[j].y;mark[j] = true;}}printf("%d\n", ans);}return 0; }?
?
總結
以上是生活随笔為你收集整理的hdu1051 Wooden Sticks的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Highlight – 代码高亮html
- 下一篇: 同时10万个事务在线,读写频繁,数据库该