結果

問題 No.2680 研究室配属
ユーザー flygonflygon
提出日時 2024-03-20 21:14:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 86,556 KB
最終ジャッジ日時 2024-03-20 21:14:44
合計ジャッジ時間 3,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,600 KB
testcase_01 AC 47 ms
55,600 KB
testcase_02 AC 43 ms
55,600 KB
testcase_03 AC 49 ms
62,176 KB
testcase_04 AC 47 ms
61,664 KB
testcase_05 AC 53 ms
66,348 KB
testcase_06 AC 56 ms
68,416 KB
testcase_07 AC 56 ms
68,412 KB
testcase_08 AC 54 ms
66,344 KB
testcase_09 AC 53 ms
64,296 KB
testcase_10 AC 76 ms
76,700 KB
testcase_11 AC 80 ms
76,828 KB
testcase_12 AC 83 ms
77,596 KB
testcase_13 AC 77 ms
76,584 KB
testcase_14 AC 84 ms
77,852 KB
testcase_15 AC 56 ms
68,416 KB
testcase_16 AC 113 ms
79,900 KB
testcase_17 AC 71 ms
76,712 KB
testcase_18 AC 92 ms
77,852 KB
testcase_19 AC 122 ms
80,796 KB
testcase_20 AC 112 ms
79,772 KB
testcase_21 AC 67 ms
72,672 KB
testcase_22 AC 104 ms
78,876 KB
testcase_23 AC 154 ms
84,508 KB
testcase_24 AC 155 ms
84,508 KB
testcase_25 AC 184 ms
86,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n,m = map(int,input().split())
a = list(map(int,input().split()))
t = [list(map(int,input().split()))[::-1] for i in range(n)]
now = [[] for i in range(m)]


left = [i for i in range(n)]
for i in range(m):
    for i in left:
        if not t[i]: continue
        x = t[i].pop()
        now[x].append(i)
    new = []
    for i in range(m):
        while len(now[i]) > a[i]:
            new.append(now[i].pop())
    left = new
    left.sort()

ans = [0]*n
for i in range(m):
    for j in now[i]:
        ans[j] = i

print(*ans)
0