結果

問題 No.1708 Quality of Contest
ユーザー tktk_snsntktk_snsn
提出日時 2021-10-16 15:05:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 950 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 61,684 KB
最終ジャッジ日時 2023-10-17 22:12:06
合計ジャッジ時間 31,337 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,224 KB
testcase_01 AC 30 ms
10,224 KB
testcase_02 AC 30 ms
10,224 KB
testcase_03 RE -
testcase_04 AC 49 ms
11,008 KB
testcase_05 AC 48 ms
11,036 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 30 ms
10,224 KB
testcase_09 AC 1,487 ms
50,784 KB
testcase_10 AC 1,793 ms
60,756 KB
testcase_11 AC 1,876 ms
59,616 KB
testcase_12 AC 1,732 ms
59,844 KB
testcase_13 AC 1,749 ms
59,620 KB
testcase_14 AC 1,726 ms
59,960 KB
testcase_15 AC 1,496 ms
60,944 KB
testcase_16 AC 1,664 ms
60,668 KB
testcase_17 AC 1,746 ms
61,448 KB
testcase_18 AC 1,748 ms
61,508 KB
testcase_19 AC 1,756 ms
61,684 KB
testcase_20 AC 1,763 ms
61,416 KB
testcase_21 AC 1,687 ms
60,388 KB
testcase_22 AC 1,674 ms
60,012 KB
testcase_23 AC 1,676 ms
60,928 KB
testcase_24 AC 1,801 ms
58,748 KB
testcase_25 AC 1,841 ms
58,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


N, M, X = map(int, input().split())
P = []
for _ in range(N):
    a, b = map(int, input().split())
    b -= 1
    P.append((-a, b))

used = [False] * M
order = []
heapq.heapify(P)
Q = []


def push(que):
    a, b = heapq.heappop(que)
    used[b] = True
    order.append((-a, b))


for _ in range(N):
    while P and used[P[0][1]]:
        heapq.heappush(Q, heapq.heappop(P))
    if P and Q:
        nw = (-P[0][0] + X)
        od = -Q[0][0]
        if (-P[0][0] + X) > -Q[0][0]:
            push(P)
        else:
            push(Q)
    elif P:
        push(P)
    else:
        push(Q)

K = int(input())
C = Counter(map(int, input().split()))
ans = 0
used = [False] * N
score = 0
for i, (a, b) in enumerate(order, 1):
    score += a
    if not used[b]:
        score += X
    used[b] = True
    ans += C[i] * score

print(ans)
0