#include<cstdio>
#include<algorithm>
#define REP(i, a, b) for(int i = (a); i < (b); i++)
using namespace std; const int MAXN = 11234;
int f[MAXN]; int main()
{
int n, m;
scanf("%d%d", &n, &m);
REP(i, 0, n)
{
int w, v;
scanf("%d%d", &w, &v);
for(int j = m; j >= w; j--)
f[j] = max(f[j], f[j - w] + v);
}
printf("%d\n", f[m]);
return 0;
}

51nod 01背包的更多相关文章

  1. 51nod 1007 正整数分组【01背包变形】

    1007 正整数分组 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题  收藏  关注 将一堆正整数分为2组,要求2组的和相差最小. 例如:1 2 3 4 5,将1 ...

  2. 51nod1085(01背包)

    题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1085 题意: 中文题诶~ 思路: 01背包模板题. 用dp[ ...

  3. 51 Nod 1007 正整数分组【类01背包】

    1007 正整数分组 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 将一堆正整数分为2组,要求2组的和相差最小. 例如:1 2 3 4 5,将1 2 4分为1组, ...

  4. [51nod]多重背包模板

    https://www.51nod.com/tutorial/course.html#!courseId=11 题目大意: 有$N$种物品和一个容量为$W$的背包.第$i$种物品最多有$c[i]$件可 ...

  5. 51nod1007(01背包)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1007 题意:中文题诶- 思路:尽量将一个数组分成两个相等的部 ...

  6. 51 nod 1007 正整数分组 (简单01背包) && csu 1547: Rectangle

    http://www.51nod.com/onlineJudge/questionCode.html#problemId=1007&noticeId=15020 求出n个数的和sum,然后用s ...

  7. UVALive 4870 Roller Coaster --01背包

    题意:过山车有n个区域,一个人有两个值F,D,在每个区域有两种选择: 1.睁眼: F += f[i], D += d[i] 2.闭眼: F = F ,     D -= K 问在D小于等于一定限度的时 ...

  8. POJ1112 Team Them Up![二分图染色 补图 01背包]

    Team Them Up! Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7608   Accepted: 2041   S ...

  9. Codeforces 2016 ACM Amman Collegiate Programming Contest A. Coins(动态规划/01背包变形)

    传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Ha ...

随机推荐

  1. [React] Refactor a Stateful List Component to a Functional Component with React PowerPlug

    In this lesson we'll look at React PowerPlug's <List /> component by refactoring a normal clas ...

  2. linux文件时间的查看和改动touch

    1. linux文件的时间 linux下文件时间主要有以下三种: 1.1 modification time(mtime) 文件改动时间.即文件内容的改动时,更新这个时间.不包含文件权限和属性的改动. ...

  3. Hibernate_9_Person和IdCard实例_一对一关系:基于主键

    1)建立Person类:(与8同样) 2)建立IdCard类:(与8同样) 3)建立持久化类:  1>保存方法(与8同样)  2>获取方法(与8同样)  3>删除方法(与8同样)   ...

  4. leetcode——Insertion Sort List 对链表进行插入排序(AC)

    Sort a linked list using insertion sort. class Solution { public: ListNode *insertionSortList(ListNo ...

  5. nodejs02---demo

    1.Hello World 打一个一个文本编辑器,在其中输入 console.log('Hello World'); 并保存为helloworld.js.打开dos窗口进入该文件的目录运行 node ...

  6. for循环练习-----ATM取款

    要求: 代码: package com.jianglai.atm; import java.util.Scanner; public class ATM { public static void ma ...

  7. 为一个支持GPRS的硬件设备搭建一台高并发服务器用什么开发比较容易?

    高并发服务器开发,硬件socket发送数据至服务器,服务器对数据进行判断,需要实现心跳以保持长连接. 同时还要接收另外一台服务器的消支付成功消息,接收到消息后控制硬件执行操作. 查了一些资料,java ...

  8. koda java

    https://kodejava.org/category/spring/spring-jdbc/

  9. <Sicily>数字反转

    一.题目描述 给定一个整数,请将该数各个位上数字反转得到一个新数.新数也应满足整数的常见形式,即除非给定的原数为零,否则反转后得到的新数的最高位数字不应为零(参见样例2). 二.输入 输入共 1 行, ...

  10. iOS——集成支付宝 系统繁忙,请稍后再试ALI40247

    问题描述:在调用支付宝时,老是显示,系统繁忙,请稍后再试ALI40247. 解决方案: 一.如何签约APP支付接口   第一步:进入管理中心:https://openhome.alipay.com/p ...