結果

問題 No.1430 Coup de Coupon
ユーザー KudeKude
提出日時 2021-03-14 14:39:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 86,708 KB
実行使用メモリ 78,776 KB
最終ジャッジ日時 2023-08-06 01:47:36
合計ジャッジ時間 7,923 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,024 KB
testcase_01 AC 70 ms
70,808 KB
testcase_02 AC 70 ms
71,048 KB
testcase_03 AC 127 ms
76,716 KB
testcase_04 AC 96 ms
76,664 KB
testcase_05 AC 95 ms
76,556 KB
testcase_06 AC 199 ms
78,384 KB
testcase_07 AC 202 ms
78,348 KB
testcase_08 AC 159 ms
78,116 KB
testcase_09 AC 368 ms
78,672 KB
testcase_10 AC 381 ms
78,348 KB
testcase_11 AC 402 ms
78,428 KB
testcase_12 AC 390 ms
78,776 KB
testcase_13 AC 395 ms
78,316 KB
testcase_14 AC 399 ms
78,416 KB
testcase_15 AC 402 ms
78,516 KB
testcase_16 AC 407 ms
78,452 KB
testcase_17 AC 413 ms
78,700 KB
testcase_18 AC 395 ms
78,292 KB
testcase_19 AC 421 ms
78,656 KB
testcase_20 AC 196 ms
77,992 KB
testcase_21 AC 149 ms
77,884 KB
testcase_22 AC 71 ms
71,288 KB
testcase_23 AC 73 ms
71,052 KB
testcase_24 AC 94 ms
75,952 KB
testcase_25 AC 113 ms
77,496 KB
testcase_26 AC 131 ms
77,388 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