結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-04 17:17:15 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 304 ms / 2,000 ms |
| コード長 | 556 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 12,928 KB |
| 最終ジャッジ日時 | 2024-10-14 00:21:05 |
| 合計ジャッジ時間 | 3,745 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
N, *M = map(int, read().split())
# %%
discount = [0]
for x in M:
discount += [(x + y) % 1000 for y in discount]
# %%
INF = 10 ** 9
dp = [INF] * (1 << N)
dp[0] = 0
for n in range(1 << N):
for i in range(N):
if not ((n >> i) & 1):
continue
m = n - (1 << i)
x = dp[m] + max(0, M[i] - discount[m])
if dp[n] > x:
dp[n] = x
# %%
print(dp[-1])
maspy