結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー rpy3cpprpy3cpp
提出日時 2016-10-21 13:05:22
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 38,968 KB
最終ジャッジ日時 2023-08-15 10:22:59
合計ジャッジ時間 17,652 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 467 ms
36,972 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 453 ms
37,912 KB
testcase_08 AC 523 ms
35,656 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 20 ms
9,484 KB
testcase_31 AC 20 ms
9,360 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 467 ms
28,528 KB
testcase_35 AC 20 ms
9,364 KB
testcase_36 AC 20 ms
9,464 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 53 ms
10,712 KB
testcase_44 AC 50 ms
10,748 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import heapq

def read_data():
    N, K = map(int, input().split())
    db = [collections.defaultdict(list) for _ in range(11)]
    for teamID in range(N):
        s, p, u = map(int, input().split())
        db[s][u].append((-p, teamID))
    return N, K, db

def solve(N, K, db):
    ans = []
    counter = [0] * (10**5 + 1)
    for dbs in db[::-1]:
        if not dbs:
            continue
        result = solve_core(dbs, counter)
        ans.extend(result)
        if len(ans) >= K:
            return ans[:K]

def solve_core(dbs, counter):
    ans = []
    que = []
    for univID, lst in dbs.items():
        lst.sort()
        p = -lst[-1][0]
        teamID = lst[-1][1]
        que.append((counter[univID], p, teamID, univID))
        counter[univID] += 1
        del lst[-1]
    heapq.heapify(que)
    while que:
        counts, p, teamID, univID = que[0]
        ans.append(teamID)
        counter[univID] += 1
        lst = dbs[univID]
        if lst:
            p, teamID = lst[-1]
            heapq.heapreplace(que, (counts + 1, p, teamID, univID))
            del dbs[univID][-1]
        else:
            heapq.heappop(que)
    return ans

N, K, db = read_data()
ans = solve(N, K, db)
for univ_key in ans:
    print(univ_key)
0