hrbust1053 http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1053

 #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
struct s{
int v,val;
}p[] ;
int dp[];
int main()
{
int t;
cin>>t;
while(t--){
memset(dp,,sizeof(dp));
int go,n;
cin>>go>>n;
for(int i=;i<n;i++)
cin>>p[i].val>>p[i].v;
for(int i=;i<n;i++){
for(int j=p[i].v;j<=go;j++){
dp[j]=max(dp[j],dp[j-p[i].v]+p[i].val);
}
} cout<<dp[go]<<endl;
}
}

DPdao的更多相关文章

随机推荐

  1. MyBatis java and MySql local variables

    <insert id="create" parameterType="models.entities.CategoryEntity"> set @c ...

  2. HackerRank "AND xor OR"

    Actually I think problem statement is somewhat misleading. No need to mention range [L, R] at all. T ...

  3. bzoj2734 集合选数

    Description <集合论与图论>这门课程有一道作业题,要求同学们求出{1, 2, 3, 4, 5}的所有满足以 下条件的子集:若 x 在该子集中,则 2x 和 3x 不能在该子集中 ...

  4. [Freescale]E9学习笔记-LTIB安装配置

    转自:http://blog.csdn.net/girlkoo/article/details/44535979 LTIB: Linux Target Image Builder Freescale提 ...

  5. 【MySQL】索引长度的一些限制

    有同学问到InnoDB的索引长度问题,简单说几个tips. MySQL的每个单表中所创建的索引长度是有限制的,且对不同存储引擎下的表有不同的限制. myisam表,单列索引,最大长度不能超过 1000 ...

  6. JavaScript对象 属性

    1.ES中的对象是完全动态的,这意味着,在程序执行的时候我们可以任意的添加,修改或删除对象的属性. var stu = { ID: 1 }; //添加新属性 stu.Name = 'ck'; cons ...

  7. 黄聪:wordpress中remove_action、add_action、 do_action()的hook钩子都有哪些

    原文地址:http://codex.wordpress.org/Plugin_API/Action_Reference muplugins_loaded After must-use plugins ...

  8. Well, let's start everything from the very beginning.

    帝都的霾仿佛亘古不变,不知觉2015年竟已快到尾声,而我在IBM也已呆了4个月.回顾过往多遇贵人,所获颇丰.最幸运的还是自己不忘初心,仍在不断成长.继续学习. 过去的几个月一直用WordPress,搭 ...

  9. ubuntu下安装jdk(rpm版)错误: 找不到或无法加载主类 解决方法

    1.官网下载jdk,linux64位,rpm格式的. 2.提取下载的文件,提取到一个目录下,我的是提取到了usr目录下了 3.终端输入:sudo gedit ~/.bashrc 会打开一个文本,在文本 ...

  10. Codeforces Round #368 (Div. 2) D. Persistent Bookcase

    Persistent Bookcase Problem Description: Recently in school Alina has learned what are the persisten ...