結果

問題 No.286 Modulo Discount Store
ユーザー GrenacheGrenache
提出日時 2015-10-09 23:37:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 4,119 ms
コンパイル使用メモリ 76,220 KB
実行使用メモリ 56,828 KB
最終ジャッジ日時 2023-09-27 10:32:14
合計ジャッジ時間 9,557 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
55,684 KB
testcase_01 AC 111 ms
55,708 KB
testcase_02 AC 131 ms
54,168 KB
testcase_03 AC 109 ms
55,952 KB
testcase_04 AC 113 ms
55,588 KB
testcase_05 AC 109 ms
55,924 KB
testcase_06 AC 128 ms
55,828 KB
testcase_07 AC 108 ms
55,604 KB
testcase_08 AC 112 ms
55,600 KB
testcase_09 AC 115 ms
55,812 KB
testcase_10 AC 120 ms
55,784 KB
testcase_11 AC 115 ms
55,828 KB
testcase_12 AC 115 ms
55,840 KB
testcase_13 AC 129 ms
55,632 KB
testcase_14 AC 113 ms
56,828 KB
testcase_15 AC 113 ms
55,828 KB
testcase_16 AC 112 ms
55,672 KB
testcase_17 AC 153 ms
55,672 KB
testcase_18 AC 121 ms
56,020 KB
testcase_19 AC 117 ms
55,840 KB
testcase_20 AC 117 ms
55,944 KB
testcase_21 AC 116 ms
55,448 KB
testcase_22 AC 112 ms
55,588 KB
testcase_23 AC 129 ms
55,604 KB
testcase_24 AC 111 ms
55,944 KB
testcase_25 AC 117 ms
55,940 KB
testcase_26 AC 110 ms
55,848 KB
testcase_27 AC 119 ms
55,596 KB
testcase_28 AC 132 ms
55,724 KB
testcase_29 AC 112 ms
55,592 KB
testcase_30 AC 112 ms
56,164 KB
testcase_31 AC 119 ms
55,708 KB
testcase_32 AC 118 ms
56,176 KB
testcase_33 AC 114 ms
55,692 KB
testcase_34 AC 113 ms
55,636 KB
testcase_35 AC 112 ms
55,624 KB
testcase_36 AC 113 ms
55,904 KB
testcase_37 AC 118 ms
55,852 KB
testcase_38 AC 112 ms
55,708 KB
testcase_39 AC 128 ms
55,620 KB
testcase_40 AC 129 ms
55,580 KB
testcase_41 AC 109 ms
55,528 KB
testcase_42 AC 110 ms
55,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;


public class Main_yukicoder286 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        m = new int[n];
        for (int i = 0; i < n; i++) {
        	m[i] = sc.nextInt();
        }

        int[] dp = new int[0x1 << n];
        dp[0] = 0;
        for (int i = 0; i < 0x1 << n; i++) {
        	for (int j = 0; j < n; j++) {
        		if ((i & (0x1 << j)) != 0) {
        			continue;
        		}
        		dp[i | (0x1 << j)] = Math.max(dp[i | (0x1 << j)], dp[i] + Math.min(sum(i) % 1000, m[j]));
        	}
        }

        System.out.println(sum((0x1 << n) - 1) - dp[(0x1 << n) - 1]);

        sc.close();
    }

    private static int n;
    private static int[] m;
    
	private static int sum(int i) {
		int ret = 0;
		for (int j = 0; j < n; j++) {
    		if ((i & (0x1 << j)) != 0) {
    			ret += m[j];
    		}
		}
		return ret;
	}
}
0