結果

問題 No.1708 Quality of Contest
ユーザー wolgnik
提出日時 2021-10-15 21:38:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 598 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 135,912 KB
最終ジャッジ日時 2024-09-17 17:19:11
合計ジャッジ時間 11,300 ms
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M, X = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(N)]

import heapq
hpush = heapq.heappush
hpop = heapq.heappop

h = []
table = [0] * (M + 1)
for x, y in a: hpush(h, (-(x + X), y))

K = int(input())
qs = list(map(int, input().split()))

qc = [0] * (N + 2)
for x in qs: qc[x + 1] -= 1
qc[1] += K
for i in range(N + 1): qc[i + 1] += qc[i]
#print(qc)

res = 0
for i in range(1, N + 1):
  while table[h[0][1]] == 1:
    x, y = hpop(h)
    hpush(h, (x + X, 0))
  x, y = hpop(h)
  if y: table[y] = 1
  x = -x
  res += x * qc[i]
  #print(x, y)
print(res)
0