結果

問題 No.893 お客様を誘導せよ
ユーザー lam6er
提出日時 2025-03-20 20:58:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 82,856 KB
実行使用メモリ 85,964 KB
最終ジャッジ日時 2025-03-20 20:58:45
合計ジャッジ時間 1,979 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

def main():
    n = int(sys.stdin.readline())
    queues = []
    total_customers = 0
    for _ in range(n):
        parts = list(map(int, sys.stdin.readline().split()))
        p_i = parts[0]
        customers = parts[1:]
        queues.append(deque(customers))
        total_customers += p_i
    
    manual_queue = []
    
    while total_customers > 0:
        for i in range(n):
            if len(queues[i]) > 0:
                customer = queues[i].popleft()
                manual_queue.append(str(customer))
                total_customers -= 1
                if total_customers == 0:
                    break
    
    print(' '.join(manual_queue))

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