結果
問題 | No.1708 Quality of Contest |
ユーザー |
|
提出日時 | 2021-10-15 22:54:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 642 ms / 2,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 166,684 KB |
最終ジャッジ日時 | 2024-09-17 17:58:47 |
合計ジャッジ時間 | 12,748 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
from heapq import heappop,heappush,heapify from collections import defaultdict N,M,X = map(int,input().split()) ab = [] dic = defaultdict(list) for _ in range(N): a,b = map(int,input().split()) ab.append((a,b)) dic[b].append(a) K = int(input()) C = list(map(int,input().split())) q = [] for key in dic.keys(): tmp = dic[key] tmp_q = [] for i in range(len(tmp)): heappush(tmp_q,-tmp[i]) x = -heappop(tmp_q) heappush(q,-(x+X)) while tmp_q: x = -heappop(tmp_q) heappush(q,-x) memo = [] while q: x = -heappop(q) memo.append(x) for i in range(N-1): memo[i+1] += memo[i] ans = 0 for i in range(K): c = C[i] if c == 0: continue ans += memo[c-1] print(ans)