Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
额,个人认为LIS比较好啊,15行解决问题#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int INF = 0x3f3f3f3f; int n, dp[10005]; pair<int, int> p[10005]; signed main(void) { while (scanf("%d", &n), n) { for (int i = 1; i <= n; i++)scanf("%d%d", &p[i].first, &p[i].second); sort(p + 1, p + 1 + n); memset(dp, 0x3f3f3f3f, sizeof(dp)); for (int i = 1; i <= n; i++)*upper_bound(dp, dp + n, p[i].second) = p[i].second; printf("%d\n", lower_bound(dp, dp + n, INF) - dp); }putchar('*'); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator