結果
問題 |
No.1708 Quality of Contest
|
ユーザー |
![]() |
提出日時 | 2021-10-16 15:05:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 950 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 62,396 KB |
最終ジャッジ日時 | 2024-09-17 19:26:43 |
合計ジャッジ時間 | 26,786 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 RE * 3 |
ソースコード
from collections import Counter import heapq import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N, M, X = map(int, input().split()) P = [] for _ in range(N): a, b = map(int, input().split()) b -= 1 P.append((-a, b)) used = [False] * M order = [] heapq.heapify(P) Q = [] def push(que): a, b = heapq.heappop(que) used[b] = True order.append((-a, b)) for _ in range(N): while P and used[P[0][1]]: heapq.heappush(Q, heapq.heappop(P)) if P and Q: nw = (-P[0][0] + X) od = -Q[0][0] if (-P[0][0] + X) > -Q[0][0]: push(P) else: push(Q) elif P: push(P) else: push(Q) K = int(input()) C = Counter(map(int, input().split())) ans = 0 used = [False] * N score = 0 for i, (a, b) in enumerate(order, 1): score += a if not used[b]: score += X used[b] = True ans += C[i] * score print(ans)