poj 1887 Testing the CATCHER 最长不升子序列
2011-10-05 17:06
399 查看
题目链接:http://poj.org/problem?id=1887
题目大意:求给定数列到最长不升子序列。关键注意到结果输出完毕后至少要输出1行空行。
代码如下:
题目大意:求给定数列到最长不升子序列。关键注意到结果输出完毕后至少要输出1行空行。
代码如下:
#include <cstdio> #include <cstdlib> #include <climits> #include <cstring> const int maxx = 100001; int num[maxx],dp[maxx]; void max(int &a,int b){ if(a<b)a = b; } int main(){ int pos = 0,nu,i,j,cas=0; while(scanf("%d",&nu)){ if(nu!=-1){ dp[pos] = 1; num[pos++] = nu; continue; } if(nu==-1 && pos==0){ break; } ++cas; for(i=0;i<pos;++i){ for(j=0;j<i;++j){ if(num[i]<=num[j]){ max(dp[i],dp[j]+1); } } } int maxx = -1; for(i=0;i<pos;++i)if(dp[i]>maxx)maxx = dp[i]; printf("Test #%d:\n",cas); printf(" maximum possible interceptions: %d\n\n",maxx); pos = 0; } return 0; }
相关文章推荐
- POJ 1887 Testing the CATCHER[最长非升子序列O(nlog(n))]
- POJ 1887 Testing the CATCHER 最长不下降序列(LIS)问题
- POJ 1887 Testing the CATCHER(最长非升子序列)
- POJ-1887-Testing the CATCHER-最长递减子序列-DP动态规划
- 【最长非升子序列】北大 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(dp_最长下降子序列)
- POJ 1887:Testing the CATCHER 求递减序列的最大值
- POJ 1887 Testingthe CATCHER (LIS:最长下降子序列)
- poj 1887 Testing the CATCHER (最长不上升子序列)
- POJ 1887:Testing the CATCHER 求递减序列的最大值
- POJ 1887 Testing the CATCHER(最长下降子序列)
- Testing the CATCHER - POJ 1887 最长递减子序列
- POJ-1887 Testing the CATCHER(dp,最长下降子序列)
- POJ 1887 —— Testing the CATCHER 最长下降子序列
- poj 1887 Testing the CATCHER_最长上升子序列
- POJ-1887 Testing the CATCHER(dp,最长下降子序列)
- poj 1887 Testing the CATCHER_最长上升子序列