結果

問題 No.1708 Quality of Contest
ユーザー titan23titan23
提出日時 2022-07-03 03:31:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 151,604 KB
最終ジャッジ日時 2023-08-18 22:50:18
合計ジャッジ時間 12,024 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,680 KB
testcase_01 AC 99 ms
71,628 KB
testcase_02 AC 90 ms
71,344 KB
testcase_03 AC 123 ms
77,996 KB
testcase_04 AC 110 ms
77,880 KB
testcase_05 AC 112 ms
77,968 KB
testcase_06 AC 110 ms
77,872 KB
testcase_07 AC 109 ms
77,660 KB
testcase_08 AC 89 ms
71,584 KB
testcase_09 AC 346 ms
151,604 KB
testcase_10 AC 300 ms
149,120 KB
testcase_11 AC 383 ms
137,112 KB
testcase_12 AC 383 ms
137,588 KB
testcase_13 AC 336 ms
136,552 KB
testcase_14 AC 343 ms
137,124 KB
testcase_15 AC 370 ms
136,260 KB
testcase_16 AC 364 ms
136,344 KB
testcase_17 AC 334 ms
137,480 KB
testcase_18 AC 338 ms
137,520 KB
testcase_19 AC 347 ms
137,660 KB
testcase_20 AC 344 ms
137,420 KB
testcase_21 AC 349 ms
136,312 KB
testcase_22 AC 352 ms
137,132 KB
testcase_23 AC 347 ms
136,048 KB
testcase_24 AC 299 ms
129,916 KB
testcase_25 AC 313 ms
130,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()

#  -----------------------  #

n, m, x = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
k = int(input())
C = list(map(int, input().split()))

dic = defaultdict(list)
for a,b in AB:
  dic[b].append(a)
for k in dic.keys():
  dic[k].sort(reverse=True)
  dic[k][0] += x
li = []
for v in dic.values():
  li.extend(v)
li.sort(reverse=True)
acc = [0] * (len(li)+1)
for i in range(len(li)):
  acc[i+1] += acc[i] + li[i]

ans = 0
for c in C:
  ans += acc[c]
print(ans)
0