結果

問題 No.1430 Coup de Coupon
ユーザー lam6er
提出日時 2025-04-16 15:24:36
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 968 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 848,496 KB
最終ジャッジ日時 2025-04-16 15:25:11
合計ジャッジ時間 4,763 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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)]

discount_list = []

for j in range(c):
    t_j, x_j = coupons[j]
    for i in range(n):
        pi = prices[i]
        if t_j == 1:
            price = max(pi - x_j, 0)
        else:
            price = (pi * (100 - x_j)) // 100
        discount = pi - price
        if discount > 0:
            discount_list.append((-discount, j, i))  # Store negative for ascending sort

# Sort the discount list to process largest discounts first
discount_list.sort()

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

for d_tuple in discount_list:
    current_d = -d_tuple[0]
    j = d_tuple[1]
    i = d_tuple[2]
    if not used_coupons[j] and not used_products[i]:
        used_coupons[j] = True
        used_products[i] = True
        total_discount += current_d

sum_p = sum(prices)
print(sum_p - total_discount)
0