結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-10-15 15:41:32
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 734 ms / 4,000 ms
コード長 847 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 56,832 KB
最終ジャッジ日時 2023-08-14 13:57:02
合計ジャッジ時間 24,221 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 613 ms
56,220 KB
testcase_01 AC 654 ms
51,576 KB
testcase_02 AC 492 ms
43,516 KB
testcase_03 AC 646 ms
46,100 KB
testcase_04 AC 662 ms
45,940 KB
testcase_05 AC 575 ms
46,104 KB
testcase_06 AC 644 ms
56,832 KB
testcase_07 AC 546 ms
47,352 KB
testcase_08 AC 491 ms
44,512 KB
testcase_09 AC 563 ms
42,892 KB
testcase_10 AC 632 ms
43,860 KB
testcase_11 AC 654 ms
49,644 KB
testcase_12 AC 678 ms
45,196 KB
testcase_13 AC 531 ms
39,840 KB
testcase_14 AC 614 ms
42,500 KB
testcase_15 AC 484 ms
40,160 KB
testcase_16 AC 657 ms
49,920 KB
testcase_17 AC 672 ms
49,264 KB
testcase_18 AC 674 ms
49,576 KB
testcase_19 AC 538 ms
39,748 KB
testcase_20 AC 585 ms
41,328 KB
testcase_21 AC 554 ms
40,348 KB
testcase_22 AC 734 ms
45,456 KB
testcase_23 AC 643 ms
42,664 KB
testcase_24 AC 524 ms
39,276 KB
testcase_25 AC 676 ms
44,664 KB
testcase_26 AC 585 ms
41,708 KB
testcase_27 AC 717 ms
44,776 KB
testcase_28 AC 500 ms
39,136 KB
testcase_29 AC 672 ms
50,188 KB
testcase_30 AC 19 ms
8,644 KB
testcase_31 AC 19 ms
8,548 KB
testcase_32 AC 614 ms
47,684 KB
testcase_33 AC 623 ms
48,024 KB
testcase_34 AC 540 ms
41,948 KB
testcase_35 AC 18 ms
8,656 KB
testcase_36 AC 18 ms
8,484 KB
testcase_37 AC 18 ms
8,656 KB
testcase_38 AC 19 ms
8,648 KB
testcase_39 AC 23 ms
8,968 KB
testcase_40 AC 24 ms
8,816 KB
testcase_41 AC 64 ms
11,688 KB
testcase_42 AC 64 ms
11,840 KB
testcase_43 AC 64 ms
12,220 KB
testcase_44 AC 66 ms
12,360 KB
testcase_45 AC 24 ms
8,988 KB
testcase_46 AC 69 ms
12,456 KB
testcase_47 AC 70 ms
12,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import collections
import heapq


def team_key(team):
    return (-team[0], team[1], team[2], team[3])


def main():
    n, k = map(int, input().split())
    data = [tuple(map(int, input().split())) for _ in range(n)]
    univ = collections.defaultdict(list)
    for i in range(n):
        u = data[i][2]
        univ[u].append(i)
    local_ranks = [-1 for _ in range(n)]
    for v in univ.values():
        v.sort(key=lambda i: (-data[i][0], data[i][1]))
        for r, i in enumerate(v):
            local_ranks[i] = r
    ts = [(data[i][0], local_ranks[i], data[i][1], i) for i in range(n)]
    if k < n // 3:
        print(*(t[-1] for t in heapq.nsmallest(k, ts, key=team_key)), sep="\n")
    else:
        ts.sort(key=team_key)
        print(*(t[-1] for t in ts[:k]), sep="\n")


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