标签:cst scanf RKE val 背包 str name out ems
Code:
#include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #include<stack> #include<string> using namespace std; void setIO(string a){ freopen((a+".in").c_str(),"r",stdin),freopen((a+".out").c_str(),"w",stdout); } void shutIO(){fclose(stdin),fclose(stdout);} #define maxn 500090 #define inf 100000000 int val[200][200], f[maxn]; int main(){ int S,D,M; scanf("%d%d%d",&S,&D,&M); for(int i=1;i<=S;++i) for(int j=1;j<=D;++j) scanf("%d",&val[j][i]); for(int i=2;i<=D;++i){ int tmp=0; memset(f,0,sizeof(f)); for(int j=1;j<=S;++j){ int cost=val[i-1][j],v=val[i][j]; for(int k=cost;k<=M;++k) f[k]=max(f[k],f[k-cost]+v-cost),tmp=max(tmp,f[k]); } M+=tmp; } printf("%d\n",M); return 0; }
[Usaco2009 Feb]Stock Market 股票市场 完全背包
标签:cst scanf RKE val 背包 str name out ems
原文地址:https://www.cnblogs.com/guangheli/p/9928985.html