結果

問題 No.286 Modulo Discount Store
ユーザー みあえみあえ
提出日時 2024-04-03 21:47:07
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 579 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 516,500 KB
最終ジャッジ日時 2024-04-03 21:47:18
合計ジャッジ時間 9,773 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
68,664 KB
testcase_01 AC 73 ms
72,552 KB
testcase_02 AC 858 ms
191,872 KB
testcase_03 AC 50 ms
61,856 KB
testcase_04 AC 59 ms
66,116 KB
testcase_05 AC 47 ms
61,860 KB
testcase_06 AC 1,832 ms
314,368 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 46 ms
61,860 KB
testcase_09 AC 45 ms
61,860 KB
testcase_10 AC 444 ms
140,032 KB
testcase_11 AC 49 ms
61,856 KB
testcase_12 AC 49 ms
61,856 KB
testcase_13 AC 962 ms
204,928 KB
testcase_14 AC 48 ms
61,860 KB
testcase_15 AC 44 ms
59,728 KB
testcase_16 AC 75 ms
72,552 KB
testcase_17 MLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N, A):
    dp = [[float("inf")] * 1000 for _ in range(1 << N)]
    dp[0][0] = 0
    for V in range(1 << N):
        for i in range(N):
            if (V >> i) & 1:
                continue
            VV = V | (1 << i)
            for r in range(1000):
                buy = max(0, A[i] - r)
                rr = (r + A[i]) % 1000
                dp[VV][rr] = min(dp[VV][rr], dp[V][r] + buy)

    return min(dp[-1])


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = solve(N, A)
    print(ans)


if __name__ == "__main__":
    main()
0