結果
問題 | No.286 Modulo Discount Store |
ユーザー |
👑 |
提出日時 | 2022-07-02 20:25:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 405 bytes |
コンパイル時間 | 2,196 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 70,100 KB |
最終ジャッジ日時 | 2024-11-27 17:37:12 |
合計ジャッジ時間 | 4,070 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
n = int(input()) m = [int(input()) for _ in range(n)] dp = [0] * (1 << n) for bit in range(1 << n): tot = 0 for i in range(n): if bit >> i & 1: tot += m[i] tot %= 1000 for i in range(n): if not bit >> i & 1: plus = min(m[i], tot) nbit = bit | (1 << i) dp[nbit] = max(dp[nbit], dp[bit] + plus) ans = sum(m) - dp[-1] print(ans)