結果

問題 No.1430 Coup de Coupon
ユーザー KudeKude
提出日時 2021-03-14 14:39:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 367 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,592 KB
実行使用メモリ 77,476 KB
最終ジャッジ日時 2024-04-23 22:21:20
合計ジャッジ時間 5,708 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,560 KB
testcase_01 AC 37 ms
52,196 KB
testcase_02 AC 35 ms
52,688 KB
testcase_03 AC 95 ms
71,800 KB
testcase_04 AC 59 ms
71,096 KB
testcase_05 AC 61 ms
70,404 KB
testcase_06 AC 144 ms
77,284 KB
testcase_07 AC 155 ms
76,884 KB
testcase_08 AC 107 ms
76,696 KB
testcase_09 AC 295 ms
77,260 KB
testcase_10 AC 299 ms
77,112 KB
testcase_11 AC 334 ms
76,892 KB
testcase_12 AC 309 ms
77,164 KB
testcase_13 AC 316 ms
76,920 KB
testcase_14 AC 321 ms
76,988 KB
testcase_15 AC 317 ms
77,052 KB
testcase_16 AC 317 ms
77,148 KB
testcase_17 AC 367 ms
77,476 KB
testcase_18 AC 319 ms
77,128 KB
testcase_19 AC 338 ms
77,388 KB
testcase_20 AC 142 ms
77,308 KB
testcase_21 AC 106 ms
76,572 KB
testcase_22 AC 35 ms
54,340 KB
testcase_23 AC 37 ms
53,364 KB
testcase_24 AC 55 ms
68,128 KB
testcase_25 AC 69 ms
74,092 KB
testcase_26 AC 89 ms
76,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0