結果
問題 | No.286 Modulo Discount Store |
ユーザー |
![]() |
提出日時 | 2020-06-05 18:51:20 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 482 ms / 2,000 ms |
コード長 | 529 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2024-12-16 06:38:12 |
合計ジャッジ時間 | 4,139 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
N = int(input()) M = [int(input()) for _ in range(N)] discount = [0] * (1 << N) for bit in range(1 << N): for i in range(N): if (bit >> i) & 1: discount[bit] += M[i] discount[bit] %= 1000 inf = 10**18 dp = [inf] * (1 << N) dp[0] = 0 for bit in range((1 << N) - 1): for i in range(N): if ~(bit >> i) & 1: bit_next = bit | (1 << i) cost = max(0, M[i] - discount[bit]) dp[bit_next] = min(dp[bit_next], dp[bit] + cost) print(dp[(1 << N) - 1])