結果
| 問題 |
No.2680 研究室配属
|
| コンテスト | |
| ユーザー |
wgrape
|
| 提出日時 | 2025-03-03 15:29:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 423 ms / 2,000 ms |
| コード長 | 692 bytes |
| コンパイル時間 | 427 ms |
| コンパイル使用メモリ | 83,020 KB |
| 実行使用メモリ | 88,616 KB |
| 最終ジャッジ日時 | 2025-03-03 15:29:42 |
| 合計ジャッジ時間 | 6,471 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
N,M = map(int,input().split())
A = list(map(int,input().split())) # 定員
q = [[i, list(map(int,input().split()))[::-1]] for i in range(N)] # 希望の高いものを後ろからpop
import heapq as hq
hq.heapify(q)
S = [[] for i in range(M)] # 各研究室に何番の生徒が入ったか
while q: # 所属していない人がいる限り
new_q = []
while q:
i, hopes = hq.heappop(q)
hope = hopes.pop()
if len(S[hope]) == A[hope]: # もう入らない
hq.heappush(new_q, (i, hopes))
else:
S[hope].append(i)
q = new_q
ans = [-1] * N
for i in range(M):
for j in S[i]:
ans[j] = i
print(*ans)
wgrape