HLG 1053 Warcraft III(背包DP)
来源:互联网 发布:淘宝网买奶粉可靠吗 编辑:程序博客网 时间:2024/05/04 20:25
Warcraft III
点击打开题目链接
dccmx likes playing Warcraft III. Now, he is teaching his girlfriend to play it. In Warcraft III, there are many kinds of units. Every unit costs some gold and lumber. Different units have different attack value.
Now question comes. Given some amount of gold and a list of types of units, how to arrange your units to maximize the attack value of your units. Assume you have infinite lumbers.
InputLine 1 contains an integer T: the number of test cases.
Next T blocks, each starts with two integers: G and U, represents the amount of gold and number of unit type. Next U lines, each contains two integers: the attack value of a type of unit and the cost.
OutputFor each test case, output the maximum total attack value in one line.
Sample Input2
100 1
20 10
300 4
100 60
250 120
120 100
35 20
Sample Output200
605
裸的完全背包问题;
代码:
#include <iostream>#include<string.h>#include<stdio.h>#define N 10000#define max(a,b) a>b?a:busing namespace std;int main(){ int t; int value[N],dp[N],v[N],V,n,i,j; while(~scanf("%d",&t)) { while(t--) { memset(dp,0,sizeof(dp)); scanf("%d%d",&V,&n); for(i=0;i<n;i++) { scanf("%d%d",&value[i],&v[i]); } for(i=0;i<n;i++) { for(j=v[i];j<=V;j++) { dp[j]=max(dp[j],dp[j-v[i]]+value[i]); } } cout<<dp[V]<<endl; } } return 0;}
- HLG 1053 Warcraft III(背包DP)
- HLG 哈理工 1053 Warcraft III (完全背包)
- HLG 1053 Warcraft III 完全背包
- HLG Warcraft III
- Hust oj 1053 Warcraft III(完全背包)
- Hrbust1053 Warcraft III (完全背包)
- HDU 3008 Warcraft (DP 背包)
- hrbust1053 Warcraft III (完全背包裸题)
- Warcraft III 分辨率设置
- ZOJ 3769 —— Diablo III(背包,DP)
- vijos1067 Warcraft III 守望者的烦恼(矩阵倍增)
- HLG 1813 小乐乐要下山 (dp)
- HLG 1360 Leyni的国家III (并查集)
- HLG 1627 猪猪罐 背包
- VOJ 1067 Warcraft III 守望者的烦恼 (矩阵快速幂+dp)
- 南邮 OJ 1443 Warcraft III
- hdu 3008 Warcraft (dp)
- HDU 3008 Warcraft (DP)
- 学习笔记:future库的日常比喻
- LDAP研究
- 使用切换器导致一台电脑分辨率被降低的解决方法
- 从你的手腕起飞的可穿戴无人机——Nixie手环
- Java 正则表达式书写详解
- HLG 1053 Warcraft III(背包DP)
- Android 不同平台分享内容的详细说明
- FileWriter与BufferedWriter的区别
- CentOS Linux安装RPMForge源
- 单片机常用按键电路
- PHP SQL查询同个表多个ID记录语句
- B/S模式(同步)AJAX技术(异步)
- Fastx-toolkit installation on Ubuntu
- 各种浏览器在线翻译,无需插件