結果

問題 No.1708 Quality of Contest
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-10-15 22:12:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,150 ms / 2,000 ms
コード長 931 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 130,656 KB
最終ジャッジ日時 2023-10-17 20:22:34
合計ジャッジ時間 17,216 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,544 KB
testcase_01 AC 39 ms
53,544 KB
testcase_02 AC 38 ms
53,544 KB
testcase_03 AC 141 ms
77,612 KB
testcase_04 AC 147 ms
77,872 KB
testcase_05 AC 146 ms
77,612 KB
testcase_06 AC 124 ms
77,576 KB
testcase_07 AC 129 ms
77,544 KB
testcase_08 AC 39 ms
53,544 KB
testcase_09 AC 1,046 ms
130,656 KB
testcase_10 AC 387 ms
124,600 KB
testcase_11 AC 791 ms
119,604 KB
testcase_12 AC 861 ms
122,940 KB
testcase_13 AC 627 ms
116,004 KB
testcase_14 AC 991 ms
119,848 KB
testcase_15 AC 1,142 ms
125,640 KB
testcase_16 AC 1,065 ms
125,296 KB
testcase_17 AC 868 ms
121,804 KB
testcase_18 AC 884 ms
122,388 KB
testcase_19 AC 999 ms
123,908 KB
testcase_20 AC 830 ms
121,508 KB
testcase_21 AC 1,043 ms
121,916 KB
testcase_22 AC 998 ms
120,128 KB
testcase_23 AC 1,150 ms
125,324 KB
testcase_24 AC 485 ms
115,628 KB
testcase_25 AC 488 ms
115,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush,heappop

n,m,x = map(int,input().split())
p = [[] for i in range(m)]
for i in range(n):
    a,b = map(int,input().split())
    p[b-1].append(a)

k = int(input())
C = list(map(int,input().split()))
count = [0]*(n+1)
for c in C:
    count[c] += 1

ans = 0
h1 = []
h2 = []
for i in range(m):
    if p[i]:
        p[i].sort()
        heappush(h1,[-p[i].pop(),i])

now = k-count[0]
for i in range(1,n+1):
    if h2 == []:
        ans += x*now
        a,ind = heappop(h1)
        ans += (-a)*now
        for j in p[ind]:
            heappush(h2,-j)
    elif h1 == []:
        a= -heappop(h2)
        ans += a*now

    else:
        if -h1[0][0]+x >= -h2[0]:
            ans += x*now
            a,ind = heappop(h1)
            ans += (-a)*now
            for j in p[ind]:
                heappush(h2,-j)
        else:
            a= -heappop(h2)
            ans += a*now
        
    now -= count[i]
print(ans)
0