結果

問題 No.1708 Quality of Contest
ユーザー O2MTO2MT
提出日時 2021-10-15 23:09:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 965 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 150,808 KB
最終ジャッジ日時 2023-10-17 20:58:43
合計ジャッジ時間 18,157 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,572 KB
testcase_01 AC 40 ms
53,572 KB
testcase_02 AC 41 ms
53,572 KB
testcase_03 AC 138 ms
77,536 KB
testcase_04 AC 155 ms
77,560 KB
testcase_05 AC 153 ms
77,820 KB
testcase_06 AC 128 ms
77,628 KB
testcase_07 AC 136 ms
77,560 KB
testcase_08 AC 40 ms
53,576 KB
testcase_09 AC 675 ms
150,808 KB
testcase_10 AC 378 ms
130,464 KB
testcase_11 AC 961 ms
134,844 KB
testcase_12 AC 918 ms
134,900 KB
testcase_13 AC 906 ms
119,476 KB
testcase_14 AC 908 ms
132,972 KB
testcase_15 AC 891 ms
143,360 KB
testcase_16 AC 885 ms
144,644 KB
testcase_17 AC 920 ms
138,416 KB
testcase_18 AC 957 ms
143,980 KB
testcase_19 AC 946 ms
133,016 KB
testcase_20 AC 912 ms
139,268 KB
testcase_21 AC 937 ms
127,024 KB
testcase_22 AC 961 ms
132,992 KB
testcase_23 AC 965 ms
144,660 KB
testcase_24 AC 620 ms
126,564 KB
testcase_25 AC 622 ms
127,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
from heapq import *

N,M,X = map(int,input().split())
D = {}

for _ in range(N):
  a,b = map(int,input().split())
  a = -a-X
  if b not in D:
    D[b] = [a]
  else:
    heappush(D[b],a)

K = int(input())
C = list(map(int,input().split()))
imos = [0]*(N+1)

for c in C:
  imos[0] += 1
  imos[c] -= 1

ac_imos = list(accumulate(imos))
E = []

for k,v in D.items():
  n = heappop(v)
  heappush(E,(n,k))

ans = 0

for c in ac_imos:
  if not E:
    break

  a,b = heappop(E)
  ans += -a*c
  
  if D[b]:
    d = heappop(D[b])
    d += X
    heappush(E,(d,b))

print(ans)
0