結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー roarisroaris
提出日時 2019-12-14 20:58:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 653 ms / 4,000 ms
コード長 580 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 107,824 KB
最終ジャッジ日時 2023-09-10 12:04:40
合計ジャッジ時間 27,888 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 646 ms
104,340 KB
testcase_01 AC 590 ms
103,304 KB
testcase_02 AC 521 ms
100,808 KB
testcase_03 AC 619 ms
103,776 KB
testcase_04 AC 612 ms
104,740 KB
testcase_05 AC 559 ms
102,516 KB
testcase_06 AC 642 ms
107,824 KB
testcase_07 AC 520 ms
100,364 KB
testcase_08 AC 548 ms
105,532 KB
testcase_09 AC 581 ms
106,268 KB
testcase_10 AC 630 ms
106,888 KB
testcase_11 AC 622 ms
106,956 KB
testcase_12 AC 598 ms
102,900 KB
testcase_13 AC 550 ms
106,676 KB
testcase_14 AC 568 ms
101,820 KB
testcase_15 AC 487 ms
101,348 KB
testcase_16 AC 635 ms
107,100 KB
testcase_17 AC 652 ms
107,052 KB
testcase_18 AC 647 ms
106,856 KB
testcase_19 AC 595 ms
106,572 KB
testcase_20 AC 557 ms
101,896 KB
testcase_21 AC 569 ms
106,944 KB
testcase_22 AC 623 ms
106,944 KB
testcase_23 AC 583 ms
107,056 KB
testcase_24 AC 547 ms
106,644 KB
testcase_25 AC 606 ms
107,128 KB
testcase_26 AC 573 ms
107,316 KB
testcase_27 AC 614 ms
107,120 KB
testcase_28 AC 551 ms
106,876 KB
testcase_29 AC 622 ms
107,048 KB
testcase_30 AC 76 ms
71,140 KB
testcase_31 AC 81 ms
71,516 KB
testcase_32 AC 637 ms
104,544 KB
testcase_33 AC 653 ms
107,120 KB
testcase_34 AC 567 ms
106,384 KB
testcase_35 AC 75 ms
71,424 KB
testcase_36 AC 74 ms
71,452 KB
testcase_37 AC 78 ms
71,416 KB
testcase_38 AC 83 ms
71,528 KB
testcase_39 AC 112 ms
76,632 KB
testcase_40 AC 110 ms
76,608 KB
testcase_41 AC 165 ms
79,620 KB
testcase_42 AC 166 ms
79,800 KB
testcase_43 AC 165 ms
79,580 KB
testcase_44 AC 151 ms
79,596 KB
testcase_45 AC 115 ms
77,540 KB
testcase_46 AC 192 ms
80,792 KB
testcase_47 AC 219 ms
81,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

N, K = map(int, input().split())
SPU = [tuple(map(int, input().split()))+(i,) for i in range(N)]
SPU.sort(key=lambda k: (-k[0], k[1]))
SPU += [(-1, -1, -1, -1)]
pq = []
cnt = [0]*N
ans = []

for i in range(N):
    Si, Pi, Ui, idx = SPU[i]
    heappush(pq, (cnt[Ui], Pi, idx))
    cnt[Ui] += 1
    
    if SPU[i][0]!=SPU[i+1][0]:
        while pq:
            _, _, idx = heappop(pq)
            ans.append(idx)
            
            if len(ans)>=K:
                for ans_i in ans:
                    print(ans_i)
                
                exit()
0