ZOJ 2136(最长递增子序列)

好久没AC了,最近真他妈烦,被人耍了。

/* File: 2136.cpp Author: ACboy Date: 2010-4-10 Result: AC Descripition: zoj 2136 */ #include <iostream> using namespace std; int data[1100]; int ans[1100]; int main() { int n; #ifndef ONLINE_JUDGE freopen("2136.txt", "r", stdin); #endif cin >> n; int c = 0; while (cin >> n) { if (c != 0) cout << endl; c++; int i, j; for (i = 0; i < n; i++) { cin >> data[i]; } ans[0] = 1; for (i = 1; i < n; i++) { int max = 0; for (j = 0; j < i; j++) { if (data[j] < data[i] && ans[j] > max) { max = ans[j]; } } ans[i] = max + 1; } int result = 0; for (i = 0; i < n; i++) { if (ans[i] > result) result = ans[i]; } cout << result << endl; } return 0; }

你可能感兴趣的:(ZOJ 2136(最长递增子序列))