結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-16 16:04:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 2,000 ms |
| コード長 | 417 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 77,068 KB |
| 最終ジャッジ日時 | 2024-06-22 03:19:25 |
| 合計ジャッジ時間 | 3,897 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
N = int(input())
M = [int(input()) for i in range(N)]
DP = [10 ** 9] * 2 ** N
X = [0] * 2 ** N
DP[0] = 0
from itertools import combinations
for i in range(1, N + 1):
for C in combinations(range(N), r=i):
x = sum([2 ** c for c in C])
X[x] = X[x - 2 ** C[0]] + M[C[0]]
DP[x] = min([DP[x - 2 ** c] + max(0, M[c] - X[x - 2 ** c] % 1000) for c in C])
print(DP[-1])