結果

問題 No.1430 Coup de Coupon
ユーザー lam6er
提出日時 2025-04-15 21:12:22
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 882 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 786,040 KB
最終ジャッジ日時 2025-04-15 21:18:08
合計ジャッジ時間 4,400 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 MLE * 1 -- * 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