結果

問題 No.2680 研究室配属
ユーザー ThetaTheta
提出日時 2024-04-18 17:11:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 81,964 KB
実行使用メモリ 102,092 KB
最終ジャッジ日時 2024-04-18 17:11:06
合計ジャッジ時間 4,792 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,352 KB
testcase_01 AC 38 ms
54,024 KB
testcase_02 AC 35 ms
53,668 KB
testcase_03 AC 40 ms
60,848 KB
testcase_04 AC 42 ms
60,384 KB
testcase_05 AC 46 ms
64,544 KB
testcase_06 AC 50 ms
65,204 KB
testcase_07 AC 49 ms
66,064 KB
testcase_08 AC 51 ms
65,532 KB
testcase_09 AC 46 ms
64,088 KB
testcase_10 AC 64 ms
78,604 KB
testcase_11 AC 74 ms
78,188 KB
testcase_12 AC 70 ms
78,624 KB
testcase_13 AC 66 ms
77,880 KB
testcase_14 AC 71 ms
78,064 KB
testcase_15 AC 53 ms
68,512 KB
testcase_16 AC 93 ms
86,056 KB
testcase_17 AC 66 ms
78,516 KB
testcase_18 AC 87 ms
83,092 KB
testcase_19 AC 119 ms
89,764 KB
testcase_20 AC 103 ms
86,036 KB
testcase_21 AC 66 ms
73,692 KB
testcase_22 AC 88 ms
82,636 KB
testcase_23 AC 142 ms
101,380 KB
testcase_24 AC 144 ms
101,392 KB
testcase_25 AC 169 ms
102,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    hope = [deque(map(int, input().split())) for _ in range(N)]

    rest = list(range(N))
    lab_assigned = [set() for _ in range(M)]
    while rest:
        not_assigned = []
        for idx in rest:
            hope_lab = hope[idx].popleft()
            if len(lab_assigned[hope_lab]) < A[hope_lab]:
                lab_assigned[hope_lab].add(idx)
            else:
                not_assigned.append(idx)
        rest = not_assigned
    assigned_lab = {}
    for lab_idx, lab_member in enumerate(lab_assigned):
        for member in lab_member:
            assigned_lab[member] = lab_idx
    ans = []
    for idx in range(N):
        ans.append(assigned_lab[idx])
    print(*ans)


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