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. shopex用户登陆错误提示在nginx下乱码问题

    http://www.test.cn/passport-aHR0cDosLHd3dy54eTAwNy5jbixwYXNzcG9ydC1hSFIwY0Rvc0xIZDNkeTU0ZVRBd055NWpi ...

  2. NOR Flash擦写和原理分析 (一)

    1. NOR FLASH 的简单介绍 NOR FLASH 是很常见的一种存储芯片,数据掉电不会丢失.NOR FLASH支持Execute On Chip,即程序可以直接在FLASH片内执行(这意味着存 ...

  3. 关于学习Perl

    Perl是一门很有用的语言,可以用它来做很多事.然而,它也仅是一门语言,掌握了Perl,你只是掌握了Computer领域的一小块知识.在学习Perl前,请明确你的学习目的,并采用正确的学习方法和资源. ...

  4. Form_Form树形结构HTree的开发(案例)

    2014-06-09 Created By BaoXinjian

  5. CF 500D New Year Santa Network tree 期望 好题

    New Year is coming in Tree World! In this world, as the name implies, there are n cities connected b ...

  6. CF 369C . Valera and Elections tree dfs 好题

    C. Valera and Elections   The city Valera lives in is going to hold elections to the city Parliament ...

  7. CMake使用教程

    转自 RichardXG 原文 CMake使用教程 CMake是一个比make更高级的编译配置工具,它可以根据不同平台.不同的编译器,生成相应的Makefile或者vcproj项目. 通过编写CMak ...

  8. php 共享内存

    共享内存主要用于进程间通信 php中的共享内存有两套扩展可以实现 1.shmop  编译时需要开启 --enable-shmop 参数 实例: $shm_key = ftok(__FILE__, 't ...

  9. bug_ _ java.lang.IllegalArgumentException: pointerIndex out of range 问题的两种解决办法

    ========== 4     如何解决java.lang.IllegalArgumentException: pointerIndex out of range? 今天遇到一个bug:java.l ...

  10. ssh-keygen+ssh-copy-id无密码登录远程LINUX主机(转载)

    From:http://blog.163.com/lgh_2002/blog/static/44017526201011333227161/ 1.创建公钥和私钥 ligh@local-host$ ss ...