結果

問題 No.893 お客様を誘導せよ
ユーザー はむ吉🐹
提出日時 2019-09-27 21:55:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,792 KB
最終ジャッジ日時 2024-09-24 10:26:00
合計ジャッジ時間 1,589 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections


def solve(num_rows, customer_rows):
    customer_queues = [collections.deque(row) for row in customer_rows]
    res_row = []
    while any(customer_queues):
        for i in range(num_rows):
            if customer_queues[i]:
                res_row.append(customer_queues[i].popleft())
    return res_row


def main():
    n = int(input())
    customer_rows = []
    for _ in range(n):
        args = [int(z) for z in input().split()]
        row = args[1:]
        customer_rows.append(row)
    res = solve(n, customer_rows)
    print(*res)


if __name__ == "__main__":
    main()
0