01背包
来源:互联网 发布:网络教育可以跨专业吗 编辑:程序博客网 时间:2024/06/05 14:47
#include<stdio.h>#include<string.h>int main(void){ int n; while(scanf("%d",&n)!=EOF&&n!=0) { int i,v,j,a[1055],s[1005],t; memset(s,0,sizeof(s)); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=1;i<n;i++) for(j=0;j<n-i;j++) if(a[j]>a[j+1]) {t=a[j];a[j]=a[j+1];a[j+1]=t; } scanf("%d",&v); if(v<5) printf("%d\n",v); else{ v=v-5; for(i=0;i<n-1;i++) for(j=v;j>=a[i];j--) s[j]=(s[j]>s[j-a[i]]+a[i]?s[j]:s[j-a[i]]+a[i]); printf("%d\n",v-s[v]-a[n-1]+5);} } return 0;}
0 0
- 【背包专题】01背包
- 01背包,完全背包
- 01背包 完全背包
- 01背包/完全背包
- 01背包,完全背包
- 背包问题---01背包
- 背包入门--01背包
- 【背包专题】01背包
- 01背包,完全背包
- 01背包,完全背包, 多重背包
- 01背包,完全背包,多重背包
- 01背包、完全背包、多重背包详解
- 01背包,完全背包,多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包模板
- jts连接数据库及部分SQL语句
- vijos1102淘淘摘苹果
- 浅谈文字编码和Unicode(上)
- 2054——A==B(占坑)
- How to build a cross compiler for your Raspberry Pi
- 01背包
- Dining poj 3281 拆点+
- Linux办公
- 2055——An easy problem
- 获取手机屏幕的宽度和高度
- AOJ-AHU-OJ-6 Hero in Maze
- 把三八节变生活节 阿里巴巴为O2O下血本
- 无聊
- 使用Django从事web开发需要具备的知识。