博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电1114
阅读量:4361 次
发布时间:2019-06-07

本文共 1077 字,大约阅读时间需要 3 分钟。

1 //完全背包,有待改良 2 #include
3 #include
4 typedef struct 5 { 6 int val,room; 7 } cus; 8 int an[10005]; 9 cus inf[505];10 int main()11 {12 int n;13 scanf("%d",&n);14 while(n--)15 {16 memset(an,0,sizeof an);17 memset(inf,0,sizeof inf);18 19 int num,rol,ror;20 scanf("%d%d%d",&rol,&ror,&num);21 22 int Room=ror-rol;23 for(int i=0; i
0; --j)29 {30 if(j!=Room && !an[j])31 continue;32 int seet = j-inf[i].room;33 if(seet < 0)34 break;35 int temp = an[j]+inf[i].val;36 if((an[seet] && an[seet]>temp) || !an[seet])37 an[seet]=temp;38 }39 }40 41 if(an[0])42 printf("The minimum amount of money in the piggy-bank is %d.\n",an[0]);43 else44 puts("This is impossible.");45 }46 return 0;47 }

 

转载于:https://www.cnblogs.com/qq188380780/p/6405017.html

你可能感兴趣的文章
HDU 1381 Crazy Search
查看>>
PLSQL
查看>>
修改计算机名
查看>>
Android-Activity的启动模式
查看>>
禅道项目管理系统整合Selenium IDE的思路
查看>>
Web 前端开发精华文章推荐(HTML5、CSS3、jQuery)【系列二十三】
查看>>
linux-nohup命令
查看>>
[LeetCode OJ] Roman to Integer
查看>>
三次握手和四次挥手
查看>>
Redis的简单动态字符串实现
查看>>
putty network error:software caused connection abort
查看>>
存储过程 <3> 和函数的区别
查看>>
高级service之ipc ADIL用法
查看>>
Django框架-基础篇
查看>>
Leetcode: Binary Tree Maximum Path Sum
查看>>
通过虚拟环境创建并开始一个django
查看>>
关于 input[type="button"] , button
查看>>
Android ViewDragHelper全然解析 自己定义ViewGroup神器
查看>>
c++ 基础 const char* 转 char*
查看>>
JS-- 小细节--你悟到了什么?
查看>>