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

最长下降子序列

Posted by yousiki at 2016-07-29 09:27:24 on Problem 1887
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 10005;
const int INF = 0x3f3f3f3f;
int n, cnt = 0, a[N], b[N];
signed main(void) {
st:	{
		scanf("%d", &a[n = 0]);
		if (a[n] == -1)return 0;
		while (scanf("%d", &a[++n]), a[n] != -1);
		memset(b, 0x3f, n << 2);
		for (int i = n - 1; i >= 0; i--)*lower_bound(b, b + n, a[i]) = a[i];
		printf("Test #%d:\n", ++cnt);
		printf("  maximum possible interceptions: %d\n\n", lower_bound(b, b + n, INF) - b);
		goto st;
	}
}

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