ny106背包问题
来源:互联网 发布:oracle查看实例端口 编辑:程序博客网 时间:2024/06/05 13:42
01.
import java.util.Scanner;
02.
public
class
Main{
03.
public
static
void
main(String[] args) {
04.
Scanner input=
new
Scanner(System.in);
05.
int
n=input.nextInt();
06.
while
(n-->0){
07.
int
dp[]=
new
int
[25];
08.
int
s=input.nextInt();
09.
int
m=input.nextInt();
10.
for
(
int
i=0;i<s;i++){
11.
int
v=input.nextInt();
12.
int
w=input.nextInt();
13.
for
(
int
k=0;k<w;k++){
14.
for
(
int
j=m;j>0;j--){
15.
dp[j]=Math.max(dp[j-1]+v, dp[j]);
16.
}
17.
}
18.
}
19.
System.out.println(dp[m]);
20.
}
21.
}
22.
}
0 0
- ny106背包问题
- NY106 背包问题
- ny106背包问题
- Ny106背包问题
- NY106——背包问题(贪心)
- 【无限背包】背包问题
- 背包问题---01背包
- 背包问题--部分背包
- 背包问题
- 背包问题
- 背包问题
- 背包问题
- 背包问题
- 背包问题
- 背包问题
- 背包问题
- 背包问题
- 背包问题
- AQS锁机制原理
- form表单四种常见的提交方式
- 如何学习
- Wall time(real time), Process time和Monotonic time.
- 结合CRIU实现cloud foundry app进程的快速dump/restore
- ny106背包问题
- 平板电脑取代PC是大势所趋?
- 垃圾收集器
- 日常记录
- Linux系统信息查看
- {jsp控制每行5个表格}
- Vector的使用
- iOS:Case.编写某个公用类时属性、init的设计
- linux 自动执行 crontab学习笔记