結果

問題 No.286 Modulo Discount Store
ユーザー hamachi470hamachi470
提出日時 2021-09-02 00:55:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 84,104 KB
最終ジャッジ日時 2023-08-19 08:05:40
合計ジャッジ時間 5,676 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,188 KB
testcase_01 AC 73 ms
76,760 KB
testcase_02 AC 109 ms
78,656 KB
testcase_03 AC 65 ms
76,156 KB
testcase_04 AC 73 ms
76,220 KB
testcase_05 AC 60 ms
71,308 KB
testcase_06 AC 112 ms
80,312 KB
testcase_07 AC 61 ms
71,428 KB
testcase_08 AC 65 ms
71,380 KB
testcase_09 AC 62 ms
70,952 KB
testcase_10 AC 87 ms
78,000 KB
testcase_11 AC 65 ms
76,008 KB
testcase_12 AC 65 ms
75,928 KB
testcase_13 AC 99 ms
78,408 KB
testcase_14 AC 61 ms
71,076 KB
testcase_15 AC 60 ms
71,296 KB
testcase_16 AC 76 ms
76,572 KB
testcase_17 AC 160 ms
84,104 KB
testcase_18 AC 95 ms
77,752 KB
testcase_19 AC 64 ms
71,200 KB
testcase_20 AC 81 ms
76,800 KB
testcase_21 AC 64 ms
71,140 KB
testcase_22 AC 63 ms
71,376 KB
testcase_23 AC 108 ms
78,692 KB
testcase_24 AC 63 ms
71,384 KB
testcase_25 AC 83 ms
76,640 KB
testcase_26 AC 63 ms
70,948 KB
testcase_27 AC 84 ms
76,720 KB
testcase_28 AC 113 ms
80,460 KB
testcase_29 AC 61 ms
71,188 KB
testcase_30 AC 62 ms
71,188 KB
testcase_31 AC 79 ms
76,592 KB
testcase_32 AC 75 ms
76,596 KB
testcase_33 AC 60 ms
71,356 KB
testcase_34 AC 63 ms
71,412 KB
testcase_35 AC 74 ms
76,448 KB
testcase_36 AC 62 ms
71,376 KB
testcase_37 AC 86 ms
76,748 KB
testcase_38 AC 64 ms
71,328 KB
testcase_39 AC 115 ms
80,528 KB
testcase_40 AC 65 ms
71,204 KB
testcase_41 AC 62 ms
71,304 KB
testcase_42 AC 63 ms
71,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
M = []
for _ in range(N):
  M.append(int(input()))

inf = 10**12
dp = [[inf]*N for _ in range(2**N)]
dp[0] = [0]*N
for bit in range(2**N):
  for r in range(N):
    if bit>>r & 1:
      continue
    dis = 0
    for l in range(N):
      if bit>>l & 1:
        dis += M[l]
        dis %= 1000
    price = max(0, M[r]-dis)
    dp[bit+2**r][r] = min(dp[bit+2**r][r], min(dp[bit])+price)

print(min(dp[2**N-1]))
0