結果

問題 No.893 お客様を誘導せよ
ユーザー lam6er
提出日時 2025-03-20 18:45:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 85,796 KB
最終ジャッジ日時 2025-03-20 18:46:06
合計ジャッジ時間 1,568 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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