結果

問題 No.2680 研究室配属
コンテスト
ユーザー flygon
提出日時 2024-03-20 21:14:37
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 155 ms / 2,000 ms
+ 869µs
コード長 749 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 243 ms
コンパイル使用メモリ 95,944 KB
実行使用メモリ 93,440 KB
最終ジャッジ日時 2026-09-06 14:11:13
合計ジャッジ時間 4,983 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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