Java 动态规划 P1441 砝码称重
题目地址
不会做借鉴了一下大佬的题解… 题解
先用DFS中枚举要去掉的砝码和已经选择过的砝码,然后用01背包记录称得砝码的最大值。
import java.util.*;
public class Main {
private static int n, m, re = 0;
private static int arr[], dp[], f[];
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
n = scan.nextInt();
m = scan.nextInt();
arr = new int[n + 1];
for (int i = 0; i < n; i++) {
arr[i] = scan.nextInt();
}
f = new
共有 0 条评论