結果
| 問題 | No.286 Modulo Discount Store |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-25 22:02:57 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 510 ms / 2,000 ms |
| コード長 | 443 bytes |
| 記録 | |
| コンパイル時間 | 96 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 13,056 KB |
| 最終ジャッジ日時 | 2024-11-17 05:39:05 |
| 合計ジャッジ時間 | 4,210 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
n=int(input())
price=[int(input()) for _ in range(n)]
INF = 10**9
dp=[INF]*(1<<n)
dp[0]=0
discount=[0]*(1<<n)
# 定価の合計を記録
for s in range(1<<n):
x=0
for j in range(n):
if (s>>j)&1:
x+=price[j]
discount[s]=x
for s in range(1<<n):
for v in range(n):
if (s>>v)&1==0:
x=max(0,price[v]-(discount[s]%1000))
dp[s|(1<<v)]=min(dp[s]+x,dp[s|(1<<v)])
print(dp[(1<<n)-1])