結果
| 問題 |
No.1708 Quality of Contest
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-15 23:09:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 790 ms / 2,000 ms |
| コード長 | 597 bytes |
| コンパイル時間 | 373 ms |
| コンパイル使用メモリ | 82,144 KB |
| 実行使用メモリ | 151,048 KB |
| 最終ジャッジ日時 | 2024-09-17 18:10:23 |
| 合計ジャッジ時間 | 14,089 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
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)