結果

問題 No.1708 Quality of Contest
ユーザー horitaka1999horitaka1999
提出日時 2021-10-15 22:54:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 653 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 166,224 KB
最終ジャッジ日時 2023-10-17 20:46:40
合計ジャッジ時間 14,347 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,380 KB
testcase_01 AC 42 ms
55,380 KB
testcase_02 AC 44 ms
55,380 KB
testcase_03 AC 152 ms
77,864 KB
testcase_04 AC 150 ms
77,636 KB
testcase_05 AC 156 ms
77,636 KB
testcase_06 AC 133 ms
77,640 KB
testcase_07 AC 132 ms
77,636 KB
testcase_08 AC 42 ms
55,420 KB
testcase_09 AC 417 ms
166,224 KB
testcase_10 AC 490 ms
132,144 KB
testcase_11 AC 645 ms
128,520 KB
testcase_12 AC 650 ms
131,684 KB
testcase_13 AC 646 ms
125,592 KB
testcase_14 AC 639 ms
132,684 KB
testcase_15 AC 635 ms
139,004 KB
testcase_16 AC 636 ms
138,728 KB
testcase_17 AC 633 ms
133,920 KB
testcase_18 AC 633 ms
135,544 KB
testcase_19 AC 646 ms
136,636 KB
testcase_20 AC 649 ms
133,352 KB
testcase_21 AC 653 ms
134,064 KB
testcase_22 AC 645 ms
132,756 KB
testcase_23 AC 644 ms
138,812 KB
testcase_24 AC 539 ms
124,512 KB
testcase_25 AC 529 ms
124,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0