Group Programming ladder match L2-014 train schedule (25 points) (the longest rising sequence)

Topic links:

L2-014 train schedule (25 points)

ideas:

with greedy look a little thought you can know the rise longest sequence in which questions seeking original sequence of

the code:

#include<bits/stdc++.h>

using namespace std;

const int maxn = 123456;
const int INF = 1 << 30;
int a[maxn];

int main() {
#ifdef MyTest
	freopen("Sakura.txt", "r", stdin);
#endif	
	int n;
	scanf("%d", &n);
	fill(a, a + n, INF);
	for(int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		*lower_bound(a, a + n, x) = x;
	}
	cout << lower_bound(a, a + n, INF) - a;
	return 0;
}
Published 280 original articles · won praise 7 · views 6695

Guess you like

Origin blog.csdn.net/qq_45228537/article/details/104045012