01背包
来源:互联网 发布:ubuntu 搭建视频服务器 编辑:程序博客网 时间:2024/06/04 19:10
题目链接:Hiho 1038
import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int V = scanner.nextInt(); int[] c = new int[N]; int[] v = new int[N]; for(int i =0 ; i< N; i++) { c[i] = scanner.nextInt(); v[i] = scanner.nextInt(); } int[] f = new int[V+1]; for(int i =0 ; i< N; i++) { for(int j = V; j>= c[i]; j--) { f[j] = Math.max(f[j],f[j-c[i]] + v[i]); } } System.out.println(f[V]); }}
阅读全文
0 0
- 【背包专题】01背包
- 01背包,完全背包
- 01背包 完全背包
- 01背包/完全背包
- 01背包,完全背包
- 背包问题---01背包
- 背包入门--01背包
- 【背包专题】01背包
- 01背包,完全背包
- 01背包,完全背包, 多重背包
- 01背包,完全背包,多重背包
- 01背包、完全背包、多重背包详解
- 01背包,完全背包,多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包
- 01背包、完全背包、多重背包模板
- python 中UnicodeEncodeError 错误
- 九度oj 题目1544:数字序列区间最小值
- uScript插件学习(三)——用户指南(自定义节点与事件)
- JS中阻止事件冒泡实例
- 24、映射器注册器MapperRegisty
- 01背包
- MAC下安装与配置MySQL
- 【Web前端】Vue.js 项目中遇到的一些问题汇总
- django1.8以上的版本怎么显示网站的 favicon.ico 图标
- 25、Result解析之ResultMapping介绍
- CSS布局:设置图片在DIV中上下左右居中(水平和垂直都居中)
- cocoapod 安装及使用
- poj3009 (dfs ,bfs)
- 从AILD与bindService谈Binder进程间通信原理(下)