結果

問題 No.1708 Quality of Contest
ユーザー 👑 tamatotamato
提出日時 2021-10-15 21:43:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 370 ms / 2,000 ms
コード長 1,184 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 81,960 KB
実行使用メモリ 134,684 KB
最終ジャッジ日時 2023-10-17 20:10:53
合計ジャッジ時間 8,304 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,700 KB
testcase_01 AC 39 ms
53,700 KB
testcase_02 AC 38 ms
53,700 KB
testcase_03 AC 113 ms
77,152 KB
testcase_04 AC 117 ms
77,340 KB
testcase_05 AC 116 ms
77,132 KB
testcase_06 AC 106 ms
76,520 KB
testcase_07 AC 104 ms
76,588 KB
testcase_08 AC 40 ms
53,700 KB
testcase_09 AC 274 ms
134,684 KB
testcase_10 AC 298 ms
132,716 KB
testcase_11 AC 348 ms
124,080 KB
testcase_12 AC 346 ms
132,724 KB
testcase_13 AC 341 ms
128,412 KB
testcase_14 AC 354 ms
132,160 KB
testcase_15 AC 369 ms
133,752 KB
testcase_16 AC 366 ms
134,428 KB
testcase_17 AC 353 ms
132,528 KB
testcase_18 AC 353 ms
132,648 KB
testcase_19 AC 361 ms
132,560 KB
testcase_20 AC 350 ms
132,436 KB
testcase_21 AC 362 ms
133,120 KB
testcase_22 AC 357 ms
132,320 KB
testcase_23 AC 370 ms
134,652 KB
testcase_24 AC 324 ms
128,376 KB
testcase_25 AC 325 ms
123,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from heapq import heappush, heappop
    input = sys.stdin.buffer.readline

    N, M, X = map(int, input().split())
    AB = []
    best = [-1] * (M+1)
    best_idx = [-1] * (M+1)
    for i in range(N):
        a, b = map(int, input().split())
        if a > best[b]:
            best[b] = a
            best_idx[b] = i
        AB.append((a, b))
    pq_unseen = [10 ** 15]
    pq_seen = [10 ** 15]
    used = set()
    for j in range(1, M+1):
        if best_idx[j] != -1:
            heappush(pq_unseen, -best[j])
            used.add(best_idx[j])
    for i in range(N):
        a, b = AB[i]
        if i not in used:
            heappush(pq_seen, -a)
    D = []
    for _ in range(N):
        p = -pq_seen[0]
        q = -pq_unseen[0] + X
        if p > q:
            D.append(p)
            heappop(pq_seen)
        else:
            D.append(q)
            heappop(pq_unseen)

    cs = [0] * (N+1)
    for i in range(N):
        cs[i+1] = cs[i] + D[i]
    K = int(input())
    C = list(map(int, input().split()))
    ans = 0
    for c in C:
        ans += cs[c]
    print(ans)


if __name__ == '__main__':
    main()
0