結果

問題 No.1430 Coup de Coupon
ユーザー lam6er
提出日時 2025-04-16 15:25:18
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 882 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 903,644 KB
最終ジャッジ日時 2025-04-16 15:26:11
合計ジャッジ時間 4,521 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 MLE * 2 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n, c = map(int, input().split())
prices = [int(input()) for _ in range(n)]
coupons = [tuple(map(int, input().split())) for _ in range(c)]

savings_list = []

for i in range(n):
    p = prices[i]
    for j in range(c):
        t, x = coupons[j]
        if t == 1:
            discounted = max(p - x, 0)
        else:
            discounted = (p * (100 - x)) // 100
        saving = p - discounted
        if saving > 0:
            savings_list.append((-saving, j, i))  # Store negative to sort in ascending

# Sort the savings in descending order of actual saving
savings_list.sort()

total_saving = 0
used_coupons = [False] * c
used_products = [False] * n

for s_neg, j, i in savings_list:
    s = -s_neg
    if not used_coupons[j] and not used_products[i]:
        total_saving += s
        used_coupons[j] = True
        used_products[i] = True

print(sum(prices) - total_saving)
0