結果

問題 No.286 Modulo Discount Store
ユーザー tobusakanatobusakana
提出日時 2022-10-23 19:54:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 76,784 KB
最終ジャッジ日時 2023-09-15 05:24:20
合計ジャッジ時間 5,936 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,212 KB
testcase_01 AC 80 ms
76,484 KB
testcase_02 AC 89 ms
76,536 KB
testcase_03 AC 74 ms
71,352 KB
testcase_04 AC 75 ms
71,492 KB
testcase_05 AC 74 ms
71,376 KB
testcase_06 AC 92 ms
76,496 KB
testcase_07 AC 71 ms
71,216 KB
testcase_08 AC 71 ms
71,160 KB
testcase_09 AC 72 ms
71,212 KB
testcase_10 AC 89 ms
76,268 KB
testcase_11 AC 71 ms
71,144 KB
testcase_12 AC 72 ms
71,072 KB
testcase_13 AC 91 ms
76,628 KB
testcase_14 AC 73 ms
71,324 KB
testcase_15 AC 72 ms
71,288 KB
testcase_16 AC 80 ms
76,524 KB
testcase_17 AC 102 ms
76,772 KB
testcase_18 AC 88 ms
76,608 KB
testcase_19 AC 73 ms
71,416 KB
testcase_20 AC 85 ms
76,644 KB
testcase_21 AC 72 ms
71,284 KB
testcase_22 AC 74 ms
71,328 KB
testcase_23 AC 89 ms
76,284 KB
testcase_24 AC 73 ms
71,148 KB
testcase_25 AC 88 ms
76,512 KB
testcase_26 AC 73 ms
71,416 KB
testcase_27 AC 90 ms
76,300 KB
testcase_28 AC 95 ms
76,504 KB
testcase_29 AC 73 ms
71,284 KB
testcase_30 AC 72 ms
71,432 KB
testcase_31 AC 86 ms
76,476 KB
testcase_32 AC 86 ms
76,784 KB
testcase_33 AC 75 ms
71,268 KB
testcase_34 AC 73 ms
71,264 KB
testcase_35 AC 81 ms
76,532 KB
testcase_36 AC 74 ms
71,152 KB
testcase_37 AC 84 ms
76,616 KB
testcase_38 AC 72 ms
71,156 KB
testcase_39 AC 93 ms
76,592 KB
testcase_40 AC 73 ms
71,300 KB
testcase_41 AC 73 ms
71,152 KB
testcase_42 AC 74 ms
71,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

N = int(readline())
M = [int(readline()) for i in range(N)]

INF = 1 << 60
dp = [INF] * (1 << N)
dp[0] = 0

for status in range(1 << N):
  # 現状態でのdiscount額を求める
  discount = 0
  for i in range(N):
    if (status >> i) & 1:
      discount += M[i]
  discount %= 1000
  for target in range(N):
    if (status >> target) & 1:
      continue
    next_status = status | (1 << target)
    price = max(0, M[target] - discount)
    if dp[next_status] > dp[status] + price:
      dp[next_status] = dp[status] + price

print(dp[-1])
0