记录编号 | 236516 | 评测结果 | AAAAA | ||
---|---|---|---|---|---|
题目名称 | 1089.[NOIP 2001PJ]装箱问题 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.002 s | ||
提交时间 | 2016-03-14 15:35:34 | 内存使用 | 0.36 MiB | ||
#include<cstdio> #include<algorithm> using namespace std; const int maxn=40,maxv=20010; int f[maxv]={0},w,c,n,v,temp=0x7fffffff; int main(){ freopen("npack.in","r",stdin); freopen("npack.out","w",stdout); scanf("%d%d",&v,&n); for(int i=1;i<=n;i++){ scanf("%d",&w); for(int j=v;j>=w;j--){ if(f[j-w]+w>f[j])f[j]=f[j-w]+w; temp=min(temp,v-f[j]); } } printf("%d",temp); return 0; }