結果

問題 No.1708 Quality of Contest
コンテスト
ユーザー rin204
提出日時 2022-01-18 02:36:28
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 424 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 147 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 155,392 KB
最終ジャッジ日時 2026-05-17 06:18:07
合計ジャッジ時間 8,592 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n, m, x = map(int, input().split())
P = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    b -= 1
    P[b].append(a)
lst = []
for p in P:
    if not p:
        continue
    p.sort(reverse = True)
    p[0] += x
    lst += p
    
lst.sort(reverse = True)
cum = [0]
for l in lst:
    cum.append(cum[-1] + l)
    
k = int(input())
C = list(map(int, input().split()))
print(sum(cum[c] for c in C))
0