Exemplo n.º 1
0
Arquivo: GSS1.cs Projeto: Dariasz/SPOJ
    private static void Main()
    {
        int arrayLength = FastIO.ReadNonNegativeInt();

        int[] sourceArray = new int[arrayLength];
        for (int i = 0; i < arrayLength; ++i)
        {
            sourceArray[i] = FastIO.ReadInt();
        }

        var solver = new GSS1(sourceArray);

        int queryCount = FastIO.ReadNonNegativeInt();

        for (int q = 0; q < queryCount; ++q)
        {
            FastIO.WriteInt(solver.Query(
                                queryStartIndex: FastIO.ReadNonNegativeInt() - 1,
                                queryEndIndex: FastIO.ReadNonNegativeInt() - 1));
            FastIO.WriteLine();
        }

        FastIO.Flush();
    }
Exemplo n.º 2
0
    // Special I/O handling is necessary to work around malformed input and get the time fast enough.
    private static void Main()
    {
        int arrayLength = int.Parse(Console.ReadLine());
        int[] sourceArray = Array.ConvertAll(
            Console.ReadLine().Split(default(char[]), StringSplitOptions.RemoveEmptyEntries),
            int.Parse);
        int queryCount = int.Parse(Console.ReadLine());

        var solver = new GSS1(sourceArray);
        var output = new StringBuilder();

        for (int i = 0; i < queryCount; ++i)
        {
            int[] line = Array.ConvertAll(
                Console.ReadLine().Split(default(char[]), StringSplitOptions.RemoveEmptyEntries),
                int.Parse);

            output.Append(solver.Query(
                queryStartIndex: line[0] - 1,
                queryEndIndex: line[1] - 1));
            output.AppendLine();
        }

        Console.Write(output);
    }