結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-27 00:25:08 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 948 ms / 2,000 ms |
| コード長 | 395 bytes |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2024-07-05 16:59:49 |
| 合計ジャッジ時間 | 5,778 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
from collections import *
inf=10**16
n = int(input())
mm =[int(input()) for _ in range(n)]
dp=[inf]*(1<<n)
dp[0] = 0
for bit in range(1<<n):
pre=dp[bit]
for i in range(n):
if bit>>i&1:continue
nbit=bit|1<<i
t1 = [mm[j] for j in range(n) if bit>>j&1]
t = sum(t1)%1000
price=max(0,mm[i]-t)
dp[nbit]=min(dp[nbit],dp[bit]+price)
print(dp[-1])