求最长递减子序列 ——>转化成求最长递增子序列!
#include<iostream> #include<cstdio> #define maxn 33000 int g[maxn],stack[maxn],ans; int research(int l,int r,int p) { if(l==r )return r; int mid=(l+r)>>1; if(p<stack[mid]) return research(l,mid,p); else return research(mid+1,r,p); } int main() { int i,j,n,ca=1,k; while(1) { scanf("%d",&k); if(k==-1) break; n=0;g[0]=k; while(1) { scanf("%d",&k); if(k!=-1) { g[++n]=k;} else { stack[0]=g[n];ans=1; for(i=n-1;i>=0;i--) { if(g[i]>stack[ans-1]) stack[ans++]=g[i]; else { int mid=research(0,ans-1,g[i]); if(g[i]<stack[mid]) stack[mid]=g[i]; else stack[mid+1]=g[i]; } } printf("Test #%d:\n",ca++); printf(" maximum possible interceptions: %d\n\n",ans); break; } } } return 0; }
您还没有登录,请您登录后再发表评论
Pku acm 第1887题 Testing the CATCHER 代码,有详细的注释,动态规划
poj 2488——dfs深度优先遍历 //给行数列数,求问能否遍历,给出字典序的一种遍历
c表示有多少种珍珠 ai 表示第i种珍珠所需的数量 pi 表示第i种珍珠的价钱 每买一种珍珠都需要付额外的10 * pi的钱,便宜的珍珠可以用贵的珍珠来代替,求最少的钱的总数。
POJ 是“北京大学程序在线评测系统”(Peking University Online Judge)的缩写,是个提供编程题目的网站,兼容Pascal、C、C++、Java、Fortran、Python等多种语言。可以按照分类,在POJ上做题。
北大POJ1426-Find The Multiple【BFS+同余模】 解题报告+AC代码
POJ 1006 源代码——中国剩余定理分析POJ 1006 源代码——中国剩余定理分析POJ 1006 源代码——中国剩余定理分析
POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're ...
poj经典动态规划题目解题报告,包括经典的动态规划题目20多道,可以作为学习动态规划系统的资料,包括题目: Pku acm 1179 Polygon Pku acm 1125 Stockbroker Grapevine Pku acm 1160 post office Pku ...
北大POJ2151-Check the difficulty of problems 解题报告+AC代码
北大POJ2983-Is the Information Reliable【差分约束+优化Bellman】 解题报告+AC代码
北大POJ1027-The Same Game 解题报告+AC代码
北大POJ1163-The Triangle 解题报告+AC代码
poj 3174 Alignment of the Planets.md
poj 4006 Genghis Khan the Conqueror.md
北大POJ1163-The Triangle
北大POJ3239-Solution to the n Queens Puzzle 解题报告+AC代码
poj 1611 The Suspects 代码 并查集的应用
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类
相关推荐
Pku acm 第1887题 Testing the CATCHER 代码,有详细的注释,动态规划
poj 2488——dfs深度优先遍历 //给行数列数,求问能否遍历,给出字典序的一种遍历
c表示有多少种珍珠 ai 表示第i种珍珠所需的数量 pi 表示第i种珍珠的价钱 每买一种珍珠都需要付额外的10 * pi的钱,便宜的珍珠可以用贵的珍珠来代替,求最少的钱的总数。
POJ 是“北京大学程序在线评测系统”(Peking University Online Judge)的缩写,是个提供编程题目的网站,兼容Pascal、C、C++、Java、Fortran、Python等多种语言。可以按照分类,在POJ上做题。
北大POJ1426-Find The Multiple【BFS+同余模】 解题报告+AC代码
POJ 1006 源代码——中国剩余定理分析POJ 1006 源代码——中国剩余定理分析POJ 1006 源代码——中国剩余定理分析
POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're ...
poj经典动态规划题目解题报告,包括经典的动态规划题目20多道,可以作为学习动态规划系统的资料,包括题目: Pku acm 1179 Polygon Pku acm 1125 Stockbroker Grapevine Pku acm 1160 post office Pku ...
北大POJ2151-Check the difficulty of problems 解题报告+AC代码
北大POJ2983-Is the Information Reliable【差分约束+优化Bellman】 解题报告+AC代码
北大POJ1027-The Same Game 解题报告+AC代码
北大POJ1163-The Triangle 解题报告+AC代码
poj 3174 Alignment of the Planets.md
poj 4006 Genghis Khan the Conqueror.md
北大POJ1163-The Triangle
北大POJ3239-Solution to the n Queens Puzzle 解题报告+AC代码
poj 1611 The Suspects 代码 并查集的应用
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类