結果

問題 No.893 お客様を誘導せよ
コンテスト
ユーザー はむ吉🐹
提出日時 2019-09-27 21:55:16
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 603 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 539 ms
コンパイル使用メモリ 20,444 KB
実行使用メモリ 19,296 KB
最終ジャッジ日時 2026-04-11 16:01:45
合計ジャッジ時間 2,824 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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