POJ 1887 Testing the CATCHER
2012-12-09 18:07
399 查看
最长下降子序列,单纯的DP算法复杂度是O(n^2),现在先放一放,等下我去弄O(nlogn)的算法。
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <string> using namespace std; const int MAXN = 10010; int A[MAXN]; int d[MAXN]; //以i为终点的最长下降序列 int n; int tot; int times; void dp() { int MAX = 0; for(int i = 1; i <= tot; i++) { d[i] = 1; for(int j = 1; j <= i-1; j++) if(A[i] < A[j]) { d[i] = max(d[i], d[j]+1); } MAX = max(MAX, d[i]); } printf(" maximum possible interceptions: %d\n\n", MAX); } void read_case() { tot = 1; while(scanf("%d", &n) && n != -1) { A[++tot] = n; } } void solve() { read_case(); printf("Test #%d:\n", ++times); dp(); } int main() { times = 0; while(scanf("%d", &n) && n != -1) { A[1] = n; solve(); } return 0; }
相关文章推荐
- poj - 1887 Testing the CATCHER
- poj 1887 Testing the CATCHER(最长递增子序列)
- poj 1887 Testing the CATCHER
- poj 1887 Testing the CATCHER
- POJ 1887 Testing the CATCHER
- POJ 1887 Testing the CATCHER.
- POJ_1887_Testing the CATCHER
- POJ 1887 Testing the CATCHER 最长不下降序列(LIS)问题
- POJ 1887 Testing the CATCHER(LIS)
- poj 1887 Testing the CATCHER
- poj 1887 Testing the CATCHER
- Poj 1887 Testing the CATCHER(LIS)
- POJ-1887 Testing the CATCHER(dp,最长下降子序列)
- poj 1887 Testing the CATCHER
- Poj 1887 Testing the CATCHER(LIS)
- POJ-1887 Testing the CATCHER(dp,最长下降子序列)
- POJ 1887 Testingthe CATCHER (LIS:最长下降子序列)
- (简单dp 水过) poj 1887 Testing the CATCHER
- Poj 1887 Testing the CATCHER
- POJ-1887-Testing the CATCHER