結果
問題 |
No.1430 Coup de Coupon
|
ユーザー |
![]() |
提出日時 | 2021-04-02 11:18:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,104 bytes |
コンパイル時間 | 468 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 77,824 KB |
最終ジャッジ日時 | 2024-12-23 04:27:13 |
合計ジャッジ時間 | 5,053 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 16 |
ソースコード
from heapq import heapify, heappop, heappush N,C = map(int, input().split()) P = [] for _ in range(N): p = int(input()) P.append(p) P.sort(reverse = True) T = []; X = [] for _ in range(C): t,x = map(int,input().split()) T.append(t); X.append(x) Fix = [] Percent = [] for i in range(C): if T[i] == 1: heappush(Fix, -X[i]) #大きい順に取り出したいのでマイナス else: heappush(Percent, -X[i]) ans = 0 for i in range(N): if len(Fix) == 0 and len(Percent) == 0: ans += P[i] elif len(Percent) == 0: discount = -Fix[0] ans += max(0, P[i] - discount) heappop(Fix) elif len(Fix) == 0: ans += P[i]*(100+Percent[0])//100 heappop(Percent) else: discount = -Fix[0] fix_price = max(P[i] - discount, 0) per_price = P[i]*(100 + Percent[0])//100 #print(fix_price,per_price,Percent[0]) if per_price <= fix_price: #%を採用 ans += per_price heappop(Percent) else: ans += fix_price heappop(Fix) print(ans)