結果

問題 No.1708 Quality of Contest
ユーザー gr1msl3ygr1msl3y
提出日時 2021-10-15 22:02:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 999 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 148,616 KB
最終ジャッジ日時 2023-10-17 20:18:37
合計ジャッジ時間 18,083 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
55,420 KB
testcase_01 AC 44 ms
55,420 KB
testcase_02 AC 44 ms
55,420 KB
testcase_03 AC 146 ms
78,164 KB
testcase_04 AC 164 ms
78,748 KB
testcase_05 AC 151 ms
77,980 KB
testcase_06 AC 135 ms
77,716 KB
testcase_07 AC 139 ms
77,716 KB
testcase_08 AC 42 ms
55,504 KB
testcase_09 AC 597 ms
144,756 KB
testcase_10 AC 826 ms
148,296 KB
testcase_11 AC 981 ms
148,028 KB
testcase_12 AC 952 ms
147,288 KB
testcase_13 AC 897 ms
147,372 KB
testcase_14 AC 999 ms
148,232 KB
testcase_15 AC 860 ms
148,604 KB
testcase_16 AC 921 ms
148,552 KB
testcase_17 AC 909 ms
145,008 KB
testcase_18 AC 941 ms
145,012 KB
testcase_19 AC 919 ms
143,228 KB
testcase_20 AC 987 ms
145,288 KB
testcase_21 AC 844 ms
147,812 KB
testcase_22 AC 894 ms
147,964 KB
testcase_23 AC 993 ms
148,616 KB
testcase_24 AC 871 ms
146,820 KB
testcase_25 AC 869 ms
146,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
import heapq as hq
N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
K = int(input())
C = list(map(int, input().split()))
D = Counter(C)

INF = 10**9
qual = 0
ct = 0
set1 = [(INF, 0)]
set2 = [(INF, 0)]
for a, b in A:
    hq.heappush(set2, (-a, b))
S = set()
ans = 0
for i in range(1, N+1):
    while set2[0][1] in S:
        a = hq.heappop(set2)
        hq.heappush(set1, a)
    v = -set1[0][0]
    w = -set2[0][0]
    if v <= w+X:
        qual += w
        ct += 1
        S.add(set2[0][1])
        hq.heappop(set2)
    else:
        qual += v
        hq.heappop(set1)
    ans += D[i]*(qual+ct*X)

print(ans)
0