結果

問題 No.1708 Quality of Contest
ユーザー titan23titan23
提出日時 2022-07-03 03:31:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 149,888 KB
最終ジャッジ日時 2024-05-06 05:16:32
合計ジャッジ時間 8,517 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,632 KB
testcase_01 AC 38 ms
53,888 KB
testcase_02 AC 39 ms
53,376 KB
testcase_03 AC 64 ms
72,832 KB
testcase_04 AC 64 ms
73,728 KB
testcase_05 AC 64 ms
73,856 KB
testcase_06 AC 62 ms
71,680 KB
testcase_07 AC 62 ms
72,064 KB
testcase_08 AC 39 ms
53,248 KB
testcase_09 AC 288 ms
142,932 KB
testcase_10 AC 265 ms
148,452 KB
testcase_11 AC 284 ms
142,284 KB
testcase_12 AC 285 ms
147,584 KB
testcase_13 AC 273 ms
136,536 KB
testcase_14 AC 300 ms
149,888 KB
testcase_15 AC 297 ms
149,456 KB
testcase_16 AC 309 ms
149,760 KB
testcase_17 AC 284 ms
147,752 KB
testcase_18 AC 282 ms
148,024 KB
testcase_19 AC 291 ms
149,760 KB
testcase_20 AC 295 ms
147,864 KB
testcase_21 AC 306 ms
149,632 KB
testcase_22 AC 288 ms
149,760 KB
testcase_23 AC 315 ms
149,544 KB
testcase_24 AC 247 ms
129,692 KB
testcase_25 AC 250 ms
129,792 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