結果

問題 No.1708 Quality of Contest
ユーザー kuro_Bkuro_B
提出日時 2023-05-18 23:26:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 560 ms / 2,000 ms
コード長 1,658 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 86,108 KB
実行使用メモリ 190,248 KB
最終ジャッジ日時 2023-08-22 13:51:54
合計ジャッジ時間 16,412 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 271 ms
95,196 KB
testcase_01 AC 275 ms
95,192 KB
testcase_02 AC 284 ms
95,100 KB
testcase_03 AC 296 ms
95,972 KB
testcase_04 AC 299 ms
96,304 KB
testcase_05 AC 298 ms
95,988 KB
testcase_06 AC 292 ms
96,020 KB
testcase_07 AC 291 ms
96,208 KB
testcase_08 AC 270 ms
95,172 KB
testcase_09 AC 540 ms
190,248 KB
testcase_10 AC 507 ms
160,776 KB
testcase_11 AC 540 ms
147,684 KB
testcase_12 AC 542 ms
149,292 KB
testcase_13 AC 531 ms
152,920 KB
testcase_14 AC 548 ms
151,600 KB
testcase_15 AC 560 ms
159,908 KB
testcase_16 AC 557 ms
159,520 KB
testcase_17 AC 547 ms
155,548 KB
testcase_18 AC 552 ms
154,864 KB
testcase_19 AC 553 ms
156,696 KB
testcase_20 AC 547 ms
158,088 KB
testcase_21 AC 552 ms
154,884 KB
testcase_22 AC 547 ms
152,000 KB
testcase_23 AC 553 ms
159,408 KB
testcase_24 AC 503 ms
149,436 KB
testcase_25 AC 506 ms
149,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

###スニペット始まり###
import sys, re
from copy import copy, deepcopy
from math import ceil, floor, sqrt,factorial, gcd, pi, degrees, radians, sin, asin, cos, acos, tan, atan2
from statistics import mean, median
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations, accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from string import ascii_uppercase, ascii_lowercase
from decimal import Decimal, ROUND_HALF_UP #四捨五入用

def input(): return sys.stdin.readline().rstrip('\n')
#easy-testのpypyでは再帰数を下げる。
if __file__=='prog.py':
    sys.setrecursionlimit(10**5)
else:
    sys.setrecursionlimit(10**6)

def lcm(a, b): return a * b // gcd(a, b)

#3つ以上の最大公約数/最小公倍数。Nを要素数、Mを数値の大きさとして、O(NlogM)
def gcd_v2(l: list): return reduce(gcd, l)
def lcm_v2(l: list): return reduce(lcm, l)

#nPk
def nPk(n, k): return factorial(n) // factorial(n - k)

#逆元
def modinv(a, mod=10**9+7): return pow(a, mod-2, mod)
INF = float('inf')
MOD = 10 ** 9 + 7
###スニペット終わり###

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

d=defaultdict(list)
for A, B in AB:
    d[B].append(A)
arr=[]
for k,v in d.items():
    v.sort(reverse=True)
    v[0]+=X
    for vv in v:
        arr.append(vv)
arr.sort(reverse=True)
cum=[0]+list(accumulate(arr))

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