HLG 1053 Warcraft III 完全背包

Warcraft III
Time Limit: 10000 MSMemory Limit: 65536 K
Total Submit: 593(198 users)Total Accepted: 263(176 users)Rating: Special Judge: No
Description

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.

Input

Line 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.

Output

For each test case, output the maximum total attack value in one line.

Sample Input

2

100 1

20 10

300 4

100 60

250 120

120 100

35 20

Sample Output

200

605

Author

dccmx

水题~

ACcode:

#pragma warning(disable:4786)//使命名长度不受限制
#pragma comment(linker, "/STACK:102400000,102400000")//手工开栈
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d%d",&x,&y)
#define rds(x) scanf("%s",x)
#define rdc(x) scanf("%c",&x)
#define ll long long int
#define maxn 100005
#define mod 1000000007
#define INF 0x3f3f3f3f //int 最大值
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i)
#define MT(x,i) memset(x,i,sizeof(x))
#define PI  acos(-1.0)
#define E  exp(1)
using namespace std;
int a[maxn],b[maxn],f[maxn];
int loop,v,n;
int main(){
    rd(loop);
    while(loop--){
        rd2(v,n);MT(f,0);
        FOR(i,1,n)rd2(a[i],b[i]);
        FOR(i,1,n)FOR(j,b[i],v)
        f[j]=max(f[j],f[j-b[i]]+a[i]);
        printf("%d\n",f[v]);
    }
    return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用:OpenCvSharp是一个OpenCV的.Net wrapper,用于开发基于OpenCV的应用程序,它与原始的OpenCV更接近,并提供了详细的使用样例。 引用:对于使用OpenCV进行图像处理的代码示例,可以使用import numpy as np import cv2来导入OpenCV库,并使用cv2.imread、cv2.imshow等函数进行图像的读取和显示。 引用:如果想要使用OpenCV进行分类器的生成,可以使用opencv_traincascade.exe命令,并提供指定的参数,例如-data用于指定生成的分类器的保存路径,-vec用于指定正样本描述文件的路径,-bg用于指定负样本文件的路径,以及其他参数如numPos、numNeg、minHitRate等。 关于"opencv hlg"的问题,根据提供的引用内容,我没有找到与"opencv hlg"相关的具体信息。可能需要提供更多背景或上下文信息来解答该问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [OpenCvSharp](https://download.csdn.net/download/qq_18865111/86722032)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [python opencv 读取图片 存储图片](https://blog.csdn.net/weixin_41799483/article/details/80829825)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [opencv分类器训练方法](https://blog.csdn.net/weixin_41799483/article/details/80567909)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值