Proud Merchants HDU
来源:互联网 发布:小语网络加速器注册 编辑:程序博客网 时间:2024/06/04 01:26
点击打开链接
主要就是由Pi+Qj<Pj+Qi 推出 Qi-Pi>Qj-Pj
参考博客点击打开链接
#include <stdio.h>#include <algorithm>using namespace std;struct node{ int w; int l; int v;};node item[510];int pack[5010];bool cmp(node n1,node n2){ return (n1.l-n1.w)<(n2.l-n2.w);}int main(){ int n,m,i,j,maxx; while(scanf("%d%d",&n,&m)!=EOF) { for(i=1;i<=n;i++) { scanf("%d%d%d",&item[i].w,&item[i].l,&item[i].v); } sort(item+1,item+n+1,cmp); for(i=0;i<=m;i++) { pack[i]=0; } for(i=1;i<=n;i++) { for(j=m;j>=item[i].w&&j>=item[i].l;j--) { if(pack[j]<pack[j-item[i].w]+item[i].v)//这部分语句被执行的次数越多 后面物品的决策条件也就越充分 { pack[j]=pack[j-item[i].w]+item[i].v; } } } maxx=0; for(i=0;i<=m;i++) { if(pack[i]>maxx) maxx=pack[i]; } printf("%d\n",maxx); } return 0;}
阅读全文
0 0
- hdu 3466 Proud Merchants
- HDU 3466 Proud Merchants
- hdu 3466 Proud Merchants
- hdu 3466 Proud Merchants
- hdu 3466 Proud Merchants
- HDU-3466-Proud Merchants
- HDU 3466 Proud Merchants
- hdu 3466 Proud Merchants
- HDU 3466 Proud Merchants
- HDU 3466 Proud Merchants
- hdu 3466 Proud Merchants
- HDU 3466 Proud Merchants
- HDU 3466 Proud Merchants
- HDU - 3466 Proud Merchants
- hdu 3466 Proud Merchants
- hdu 3466 Proud Merchants
- hdu 3466 Proud Merchants
- HDU 3466 Proud Merchants
- 【Python】Matplotlib画图(四)——折线图
- 【Lua】迭代器初学
- MySQL语句之or/and
- 20170904多个docker容器中同时搭建多套ceph集群(一)---docker网络模式的了解
- 【JS开发】电商相关自用小插件
- Proud Merchants HDU
- Python 函数
- myBatis学习——SqlSession对象获取的封装工具类
- Android自定义开机和关机动画
- 第5章 索引与算法,第6章 锁
- Git 分布式版本控制
- JavaScript对JSON的解析
- scala 时间戳比较大小
- 前端存储-cookie-sessionStorage-loacalStorage