結果
| 問題 |
No.2680 研究室配属
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-01 14:00:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 414 ms / 2,000 ms |
| コード長 | 1,287 bytes |
| コンパイル時間 | 483 ms |
| コンパイル使用メモリ | 82,636 KB |
| 実行使用メモリ | 91,488 KB |
| 最終ジャッジ日時 | 2025-05-01 14:00:38 |
| 合計ジャッジ時間 | 6,042 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
## https://yukicoder.me/problems/no/2680
import heapq
from collections import deque
def main():
N, M = map(int, input().split())
A = list(map(int, input().split()))
T = []
for _ in range(N):
T.append(list(map(int, input().split())))
queues = [[] for _ in range(M)]
queue = deque()
index = 0
fixed_set = [[] for _ in range(M)]
for i in range(N):
queue.append(i)
while len(queue) > 0 and index < M:
while len(queue) > 0:
i = queue.popleft()
t = T[i][index]
heapq.heappush(queues[t], -i)
for m in range(M):
x = A[m] - len(fixed_set[m])
if x < len(queues[m]):
z = len(queues[m]) - x
for _ in range(z):
y = heapq.heappop(queues[m])
y = -y
queue.append(y)
for m in range(M):
for x in queues[m]:
fixed_set[m].append(-x)
queues[m].clear()
index += 1
answers = [-1] * N
for m in range(M):
for x in fixed_set[m]:
answers[x] = m
print(" ".join(map(str, answers)))
if __name__ == "__main__":
main()