結果

問題 No.893 お客様を誘導せよ
ユーザー mbanmban
提出日時 2019-09-27 21:28:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 2,888 bytes
コンパイル時間 4,255 ms
コンパイル使用メモリ 111,564 KB
実行使用メモリ 31,672 KB
最終ジャッジ日時 2023-10-25 01:47:53
合計ジャッジ時間 4,671 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,268 KB
testcase_01 AC 25 ms
24,268 KB
testcase_02 AC 32 ms
24,268 KB
testcase_03 AC 49 ms
29,608 KB
testcase_04 AC 50 ms
29,604 KB
testcase_05 AC 47 ms
29,360 KB
testcase_06 AC 41 ms
26,316 KB
testcase_07 AC 25 ms
24,200 KB
testcase_08 AC 70 ms
31,672 KB
testcase_09 AC 26 ms
24,268 KB
testcase_10 AC 25 ms
24,256 KB
testcase_11 AC 27 ms
24,268 KB
testcase_12 AC 26 ms
24,268 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        Queue<int>[]Q = new Queue<int>[N];
        for (int i = 0; i < N; i++)
        {
            Q[i] = new Queue<int>();
            int P = sc.NextInt();
            for (int j = 0; j < P; j++)
            {
                Q[i].Enqueue(sc.NextInt());
            }
        }
        
        List<int> ans = new List<int>();

        while (true)
        {
            bool b = false;
            for (int i = 0; i < N; i++)
            {
                if (Q[i].Count > 0)
                {
                    ans.Add(Q[i].Dequeue());
                    b = true;
                }
            }
            if(!b)
                break;
        }
        
        Console.WriteLine(string.Join(" ",ans));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}
0