結果

問題 No.286 Modulo Discount Store
ユーザー qibqib
提出日時 2022-10-29 13:10:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 83,284 KB
最終ジャッジ日時 2023-09-20 17:29:24
合計ジャッジ時間 8,320 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,124 KB
testcase_01 AC 100 ms
76,700 KB
testcase_02 AC 121 ms
78,432 KB
testcase_03 AC 81 ms
75,864 KB
testcase_04 AC 86 ms
76,252 KB
testcase_05 AC 74 ms
71,288 KB
testcase_06 AC 145 ms
80,000 KB
testcase_07 AC 75 ms
71,444 KB
testcase_08 AC 73 ms
71,212 KB
testcase_09 AC 73 ms
71,324 KB
testcase_10 AC 117 ms
77,968 KB
testcase_11 AC 77 ms
76,036 KB
testcase_12 AC 79 ms
75,956 KB
testcase_13 AC 131 ms
78,768 KB
testcase_14 AC 77 ms
71,240 KB
testcase_15 AC 73 ms
71,412 KB
testcase_16 AC 94 ms
76,436 KB
testcase_17 AC 216 ms
83,284 KB
testcase_18 AC 116 ms
78,088 KB
testcase_19 AC 75 ms
71,124 KB
testcase_20 AC 108 ms
77,160 KB
testcase_21 AC 74 ms
71,344 KB
testcase_22 AC 73 ms
71,144 KB
testcase_23 AC 128 ms
78,840 KB
testcase_24 AC 74 ms
71,380 KB
testcase_25 AC 110 ms
77,472 KB
testcase_26 AC 75 ms
71,348 KB
testcase_27 AC 110 ms
77,692 KB
testcase_28 AC 148 ms
80,120 KB
testcase_29 AC 76 ms
71,344 KB
testcase_30 AC 75 ms
71,304 KB
testcase_31 AC 102 ms
76,252 KB
testcase_32 AC 100 ms
76,440 KB
testcase_33 AC 77 ms
71,204 KB
testcase_34 AC 80 ms
71,420 KB
testcase_35 AC 98 ms
76,484 KB
testcase_36 AC 80 ms
71,124 KB
testcase_37 AC 113 ms
77,468 KB
testcase_38 AC 78 ms
71,124 KB
testcase_39 AC 146 ms
80,432 KB
testcase_40 AC 75 ms
71,280 KB
testcase_41 AC 80 ms
71,352 KB
testcase_42 AC 75 ms
71,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1 << 60

n = int(input())
m = [int(input()) for _ in range(n)]

dp = [[INF for _ in range(n)] for _ in range(1 << n)]
for src in range(n):
  dp[0][src] = 0

for mask in range(1 << n):
  dpm = dp[mask]

  cnt = 0
  for v in range(n):
    if (mask >> v) & 1 != 0:
      cnt = (cnt + m[v]) % 1000

  for cur in range(n):
    if dpm[cur] == INF:
      continue

    for nxt in range(n):
      if (mask >> nxt) & 1 != 0:
        continue

      dp[mask | (1 << nxt)][nxt] = min(dp[mask | (1 << nxt)][nxt], dpm[cur] + max(0, m[nxt] - cnt))

print(min(dp[-1]))
0