結果
問題 | No.1708 Quality of Contest |
ユーザー |
![]() |
提出日時 | 2021-10-15 22:02:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 950 ms / 2,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 149,260 KB |
最終ジャッジ日時 | 2024-09-17 17:30:43 |
合計ジャッジ時間 | 17,327 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
from collections import Counterimport heapq as hqN, M, X = map(int, input().split())A = [list(map(int, input().split())) for _ in range(N)]K = int(input())C = list(map(int, input().split()))D = Counter(C)INF = 10**9qual = 0ct = 0set1 = [(INF, 0)]set2 = [(INF, 0)]for a, b in A:hq.heappush(set2, (-a, b))S = set()ans = 0for i in range(1, N+1):while set2[0][1] in S:a = hq.heappop(set2)hq.heappush(set1, a)v = -set1[0][0]w = -set2[0][0]if v <= w+X:qual += wct += 1S.add(set2[0][1])hq.heappop(set2)else:qual += vhq.heappop(set1)ans += D[i]*(qual+ct*X)print(ans)