結果
問題 | No.1708 Quality of Contest |
ユーザー |
![]() |
提出日時 | 2021-10-16 15:06:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,993 ms / 2,000 ms |
コード長 | 900 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 62,316 KB |
最終ジャッジ日時 | 2024-12-20 10:01:11 |
合計ジャッジ時間 | 35,493 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
from collections import Counterimport heapqimport sysinput = sys.stdin.buffer.readlinesys.setrecursionlimit(10 ** 7)N, M, X = map(int, input().split())P = []for _ in range(N):a, b = map(int, input().split())b -= 1P.append((-a, b))used = [False] * Morder = []heapq.heapify(P)Q = []def push(que):a, b = heapq.heappop(que)used[b] = Trueorder.append((-a, b))for _ in range(N):while P and used[P[0][1]]:heapq.heappush(Q, heapq.heappop(P))if P and Q: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 = 0used = [False] * Mscore = 0for i, (a, b) in enumerate(order, 1):score += aif not used[b]:score += Xused[b] = Trueans += C[i] * scoreprint(ans)