摘要: Bone Collector/* 标准的01背包问题。状态转移方程 f[i][v] = max{f[i-1][v-c[i]]+v[i],f[i-1][v]} */ #include #include #include using namespace std; int main() { int T,N,V,f[1001],vol[1001],val[1001],tem; cin>>T; while(T--) { cin>>N>>V; for(int i=0;i>val[i]; } for(int i=0;i>vol[i]; } memset(f,0 阅读全文
posted @ 2013-04-22 15:56 VeryBigMan 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Max Sum#include using namespace std; int a[100001]; int main() { int T; int i,n,position1,end,thissum,maxsum,begin; cin>>T; for(int tt=1;tt>n; for(i=0;imaxsum) //当前值比最大值大,则头尾都要改 { maxsum=thissum; begin=position1; end=i; } } printf("Case %d:\n%d %d %d\n",tt,maxsum,begin+1,... 阅读全文
posted @ 2013-04-22 15:52 VeryBigMan 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 超级楼梯#include using namespace std; int main() { int n; int T; int a[41]; a[1]=0; a[2]=1; a[3]=2; for(int i=4;i>T; while(T--) { cin>>n; cout using namespace std; int main() { int T; long long a[51]; a[1]=1; a[2]=2; for(int i=3;i>T; while(T--) { int A,B; cin>>A>>B; cout using... 阅读全文
posted @ 2013-04-22 15:50 VeryBigMan 阅读(90) 评论(0) 推荐(0) 编辑