結果
問題 | No.1430 Coup de Coupon |
ユーザー | Kude |
提出日時 | 2021-03-14 14:39:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 386 ms / 2,000 ms |
コード長 | 752 bytes |
コンパイル時間 | 283 ms |
コンパイル使用メモリ | 82,232 KB |
実行使用メモリ | 77,472 KB |
最終ジャッジ日時 | 2024-11-06 04:36:43 |
合計ジャッジ時間 | 6,596 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
n, c = map(int, input().split()) p = sorted((int(input()) for _ in range(n)), reverse=True) tot = sum(p) c1 = [] c2 = [] for _ in range(c): t, x = map(int, input().split()) if t == 1: c1.append(x) else: c2.append(x) c1.sort(reverse=True) c2.sort(reverse=True) s1 = len(c1) s2 = len(c2) INF = 10 ** 18 dp = [-INF] * (s1 + 1) dp[0] = 0 for i, pi in enumerate(p): ndp = dp[:] for j in range(i + 1): # used j coupons in c1 k = i - j if not (0 <= j <= s1 and 0 <= k <= s2): continue if j < s1: ndp[j+1] = max(ndp[j+1], dp[j] + min(c1[j], pi)) if k < s2: ndp[j] = max(ndp[j], dp[j] + pi * c2[k] // 100) dp = ndp ans = tot - max(dp) print(ans)