結果

問題 No.286 Modulo Discount Store
ユーザー scachescache
提出日時 2015-11-18 19:44:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 5,346 ms
コンパイル使用メモリ 74,724 KB
実行使用メモリ 57,988 KB
最終ジャッジ日時 2023-10-11 18:00:40
合計ジャッジ時間 13,411 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,020 KB
testcase_01 AC 122 ms
55,848 KB
testcase_02 AC 135 ms
55,976 KB
testcase_03 AC 123 ms
55,488 KB
testcase_04 AC 126 ms
57,988 KB
testcase_05 AC 116 ms
39,324 KB
testcase_06 AC 130 ms
39,900 KB
testcase_07 AC 115 ms
39,456 KB
testcase_08 AC 113 ms
39,096 KB
testcase_09 AC 115 ms
39,120 KB
testcase_10 AC 120 ms
39,260 KB
testcase_11 AC 118 ms
39,532 KB
testcase_12 AC 117 ms
39,324 KB
testcase_13 AC 127 ms
39,328 KB
testcase_14 AC 114 ms
39,056 KB
testcase_15 AC 116 ms
39,024 KB
testcase_16 AC 115 ms
39,228 KB
testcase_17 AC 135 ms
39,884 KB
testcase_18 AC 122 ms
39,608 KB
testcase_19 AC 119 ms
39,156 KB
testcase_20 AC 119 ms
39,464 KB
testcase_21 AC 116 ms
39,184 KB
testcase_22 AC 115 ms
39,140 KB
testcase_23 AC 129 ms
39,572 KB
testcase_24 AC 118 ms
39,300 KB
testcase_25 AC 123 ms
40,208 KB
testcase_26 AC 119 ms
39,184 KB
testcase_27 AC 118 ms
40,296 KB
testcase_28 AC 129 ms
39,648 KB
testcase_29 AC 115 ms
39,508 KB
testcase_30 AC 119 ms
39,320 KB
testcase_31 AC 118 ms
39,388 KB
testcase_32 AC 118 ms
40,200 KB
testcase_33 AC 117 ms
40,184 KB
testcase_34 AC 116 ms
39,356 KB
testcase_35 AC 117 ms
40,264 KB
testcase_36 AC 116 ms
40,184 KB
testcase_37 AC 119 ms
39,392 KB
testcase_38 AC 120 ms
39,656 KB
testcase_39 AC 132 ms
39,472 KB
testcase_40 AC 118 ms
39,736 KB
testcase_41 AC 121 ms
39,548 KB
testcase_42 AC 118 ms
39,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main286 {
    public static void main(String[] args) {
        new Main286();
    }

    public Main286() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] m = new int[n];
        for (int i = 0; i < n; i++)
            m[i] = sc.nextInt();

        solve(m);
    }

    private void solve(int[] m) {
        int n = m.length;

        int[] total = new int[1 << n];
        int[] min = new int[1 << n];
        Arrays.fill(min, Integer.MAX_VALUE);
        min[0]= 0;

        for (int i = 1; i < (1 << n); i++) {
            int cur = 1;
            for (int j = 0; j < n; j++) {
                if (i==cur || (i & cur) > 0) {
                    min[i] = Math.min(min[i], min[i ^ cur] + Math.max(0, m[j] - total[i^cur] % 1000));
                    total[i] = total[i^cur] + m[j];
                }
                cur <<= 1;
            }
        }

        System.out.println(min[(1 << n) - 1]);
    }


}
0