結果

問題 No.2680 研究室配属
ユーザー Yakumo221
提出日時 2024-03-20 21:24:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 85,120 KB
最終ジャッジ日時 2024-09-30 07:10:22
合計ジャッジ時間 3,523 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int, input().split())
alist = list(map(int, input().split()))

tlist = [list(map(int, input().split())) for i in range(n)]

que = list(range(n)[::-1])

cntlist = [0 for i in range(m)]
ans = [0 for i in range(n)]

for i in range(m):
    nq = []

    while que:
        hito = que.pop()
        heya = tlist[hito][i]

        if cntlist[heya] < alist[heya]:
            cntlist[heya] += 1
            ans[hito] = heya
        else:
            nq.append(hito)
    
    que = sorted(nq, reverse=True)

print(*ans)
0