結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー mkawa2mkawa2
提出日時 2020-04-23 08:01:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 512 ms / 4,000 ms
コード長 1,267 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 46,460 KB
最終ジャッジ日時 2023-08-03 06:56:29
合計ジャッジ時間 18,758 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 459 ms
43,848 KB
testcase_01 AC 363 ms
43,912 KB
testcase_02 AC 264 ms
42,532 KB
testcase_03 AC 400 ms
43,012 KB
testcase_04 AC 407 ms
42,332 KB
testcase_05 AC 321 ms
43,072 KB
testcase_06 AC 512 ms
46,460 KB
testcase_07 AC 269 ms
42,496 KB
testcase_08 AC 434 ms
46,112 KB
testcase_09 AC 446 ms
45,456 KB
testcase_10 AC 437 ms
42,100 KB
testcase_11 AC 466 ms
42,108 KB
testcase_12 AC 386 ms
39,140 KB
testcase_13 AC 394 ms
42,136 KB
testcase_14 AC 307 ms
39,028 KB
testcase_15 AC 378 ms
42,052 KB
testcase_16 AC 469 ms
41,996 KB
testcase_17 AC 467 ms
42,052 KB
testcase_18 AC 488 ms
42,088 KB
testcase_19 AC 397 ms
42,088 KB
testcase_20 AC 297 ms
39,188 KB
testcase_21 AC 411 ms
42,012 KB
testcase_22 AC 462 ms
42,108 KB
testcase_23 AC 434 ms
42,040 KB
testcase_24 AC 390 ms
42,080 KB
testcase_25 AC 443 ms
42,032 KB
testcase_26 AC 416 ms
42,040 KB
testcase_27 AC 442 ms
42,024 KB
testcase_28 AC 388 ms
42,092 KB
testcase_29 AC 464 ms
42,024 KB
testcase_30 AC 21 ms
8,684 KB
testcase_31 AC 20 ms
8,700 KB
testcase_32 AC 438 ms
40,048 KB
testcase_33 AC 494 ms
43,260 KB
testcase_34 AC 452 ms
45,760 KB
testcase_35 AC 21 ms
8,792 KB
testcase_36 AC 21 ms
8,680 KB
testcase_37 AC 21 ms
8,728 KB
testcase_38 AC 21 ms
8,668 KB
testcase_39 AC 24 ms
8,900 KB
testcase_40 AC 24 ms
8,992 KB
testcase_41 AC 43 ms
11,796 KB
testcase_42 AC 48 ms
12,028 KB
testcase_43 AC 47 ms
11,924 KB
testcase_44 AC 42 ms
11,748 KB
testcase_45 AC 25 ms
9,048 KB
testcase_46 AC 62 ms
11,812 KB
testcase_47 AC 64 ms
12,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n,k=MI()
    spu=LLI(n)
    hp=[]
    uni=defaultdict(int)
    for i,(s,p,u) in enumerate(spu):
        heappush(hp,(-s,p,u,i))
    while 1:
        s,p,u,i=heappop(hp)
        score=s
        cpi=[]
        c = uni[u]
        uni[u] += 1
        heappush(cpi, (c, p, i))
        while hp and hp[0][0]==score:
            s, p, u, i = heappop(hp)
            c = uni[u]
            uni[u] += 1
            heappush(cpi, (c, p, i))
        while cpi:
            c,p,i=heappop(cpi)
            print(i)
            k-=1
            if k==0:exit()

main()
0