poj 1887 Testing the CATCHER_最长上升子序列
2013-12-02 21:28
369 查看
题意:题目太长没看,直接看输入输出猜出是最长下降子序列
用了以前的代码直接a了,做法类似贪心,把最小的顺序数存在数组里面,每次二分更新数组得出最长上升子序列
用了以前的代码直接a了,做法类似贪心,把最小的顺序数存在数组里面,每次二分更新数组得出最长上升子序列
#include<iostream> #include<cstdio> using namespace std; int main() { int dp[40002],a[40002],n,t,i,low,up,top,mid,max,tmp,k,b[40002],cas=1; while(1) { scanf("%d",&tmp); if(tmp==-1) break; k=1; b[k++]=tmp; while(scanf("%d",&tmp)){ if(tmp==-1) break; b[k++]=tmp; } k--; for(i=1;i<=k;i++) a[i]=b[k-i+1]; top=1; dp[1]=a[1]; max=0; for(i=1;i<=k;i++) { low=1; up=top; while(low<=up) { mid=(low+up)/2; if(dp[mid]>=a[i]) up=mid-1; else low=mid+1; } dp[low]=a[i]; if(low>top) top++; } printf("Test #%d:\n",cas++); printf(" maximum possible interceptions: %d\n\n",top); } return 0; }
相关文章推荐
- poj 1887 Testing the CATCHER_最长上升子序列
- POJ-1887-Testing the CATCHER【最长不上升子序列nlogn】
- poj 1887 Testing the CATCHER (最长不上升子序列)
- POJ 1887-Testing the CATCHER(dp_最长下降子序列)
- POJ 1887 Testingthe CATCHER (LIS:最长下降子序列)
- Testing the CATCHER - POJ 1887 最长递减子序列
- POJ 1887 Testing the CATCHER(最长下降子序列)
- POJ 1887 Testing the CATCHER(最长递减子序列)
- POJ-1887 Testing the CATCHER(dp,最长下降子序列)
- POJ-1887 Testing the CATCHER(dp,最长下降子序列)
- POJ 1887 —— Testing the CATCHER 最长下降子序列
- poj 1887 Testing the CATCHER(最长递增子序列)
- POJ 1887 Testing the CATCHER(最长非升子序列)
- Pku1887----Testing the CATCHER (经典动态规划题:最长下降子序列),,,,,捎带pku2533---Longest Ordered Subsequence
- 【最长非升子序列】北大 POJ 1887 Testing the CATCHER
- POJ-1887-Testing the CATCHER-最长递减子序列-DP动态规划
- POJ 1887 Testing the CATCHER 最长不下降序列(LIS)问题
- poj 1887 Testing the CATCHER 最长不升子序列
- POJ 1887 Testing the CATCHER[最长非升子序列O(nlog(n))]
- poj 1887 Testing the CATCHER