結果
問題 |
No.1708 Quality of Contest
|
ユーザー |
![]() |
提出日時 | 2025-02-26 20:59:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 940 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 159,112 KB |
最終ジャッジ日時 | 2025-02-26 20:59:44 |
合計ジャッジ時間 | 14,131 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 20 |
ソースコード
from heapq import * N,M,X = map(int,input().split()) AB = [list(map(int,input().split())) for _ in range(N)] K = int(input()) C = list(map(int,input().split())) J = [[] for _ in range(M)] Y = [0] * N Q1 = [] Q2 = [] solved = set() for a,b in AB: b -= 1 J[b].append(a) for c in C: if c > 0: Y[c - 1] += 1 for i in range(M): if J[i]: J[i].sort() x = J[i].pop() heappush(Q1,(-x,i)) ans = 0 tmp = 0 for i in range(N): if Q2: if Q1: if Q1[0][0] - M < Q2[0][0]: x, jn = heappop(Q1) tmp += -x + X else: x, jn = heappop(Q2) tmp += -x else: x, jn = heappop(Q2) tmp += -x else: if Q1: x, jn = heappop(Q1) tmp += -x + X if J[jn]: heappush(Q2,(-J[jn].pop(),jn)) ans += tmp * Y[i] #print(i,tmp,Y[i],ans) print(ans)