結果

問題 No.286 Modulo Discount Store
ユーザー ああいいああいい
提出日時 2022-03-17 22:45:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 69,896 KB
最終ジャッジ日時 2024-04-09 21:20:31
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,976 KB
testcase_01 AC 43 ms
62,580 KB
testcase_02 AC 48 ms
66,296 KB
testcase_03 AC 32 ms
52,892 KB
testcase_04 AC 33 ms
52,900 KB
testcase_05 AC 33 ms
53,032 KB
testcase_06 AC 53 ms
67,276 KB
testcase_07 AC 31 ms
53,188 KB
testcase_08 AC 31 ms
52,616 KB
testcase_09 AC 32 ms
52,856 KB
testcase_10 AC 46 ms
64,540 KB
testcase_11 AC 32 ms
52,600 KB
testcase_12 AC 35 ms
54,132 KB
testcase_13 AC 49 ms
66,032 KB
testcase_14 AC 32 ms
52,824 KB
testcase_15 AC 32 ms
52,832 KB
testcase_16 AC 41 ms
61,704 KB
testcase_17 AC 63 ms
69,896 KB
testcase_18 AC 46 ms
64,804 KB
testcase_19 AC 33 ms
52,924 KB
testcase_20 AC 44 ms
64,368 KB
testcase_21 AC 32 ms
52,608 KB
testcase_22 AC 32 ms
52,732 KB
testcase_23 AC 50 ms
67,176 KB
testcase_24 AC 33 ms
52,340 KB
testcase_25 AC 47 ms
65,680 KB
testcase_26 AC 31 ms
52,312 KB
testcase_27 AC 46 ms
65,224 KB
testcase_28 AC 51 ms
67,308 KB
testcase_29 AC 31 ms
52,436 KB
testcase_30 AC 30 ms
53,224 KB
testcase_31 AC 43 ms
64,264 KB
testcase_32 AC 44 ms
65,188 KB
testcase_33 AC 31 ms
52,432 KB
testcase_34 AC 31 ms
51,944 KB
testcase_35 AC 38 ms
62,772 KB
testcase_36 AC 30 ms
52,244 KB
testcase_37 AC 46 ms
66,272 KB
testcase_38 AC 31 ms
52,364 KB
testcase_39 AC 51 ms
67,044 KB
testcase_40 AC 31 ms
53,584 KB
testcase_41 AC 31 ms
52,892 KB
testcase_42 AC 34 ms
52,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
M = [int(input()) for _ in range(N)]
inf = 10 ** 7
dp = [inf] * (1 << N)
for i in range(N):
    mask = 1 << i
    dp[mask] = M[i]
Sum = [0] * (1 << N)
for bit in range(1 << N):
    for i in range(N):
        mask = 1 << i
        if bit & mask == 0:
            Sum[bit | mask] = Sum[bit] + M[i]
            
for bit in range(1,1 << N):
    r = Sum[bit] % 1000
    for i in range(N):
        mask = 1 << i
        if bit & mask == 0:
            dp[bit | mask] = min(dp[bit | mask],dp[bit] + max(0,M[i]-r))
print(dp[-1])
0