Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

额,个人认为LIS比较好啊,15行解决问题

Posted by yousiki at 2016-07-28 16:37:50 on Problem 1609
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator