#K73722. Gameplay Analysis

    ID: 34039 Type: Default 1000ms 256MiB

Gameplay Analysis

Gameplay Analysis

You are given the performance data of a player named Karl over N stages. At each stage, Karl collects a certain number of coins. Your task is to analyze his gameplay by answering several queries.

For each query, you will be given two indices L and R (1-indexed) which represent a consecutive period of stages. You need to calculate two quantities for that period:

  • The total coins collected, i.e., \(\sum_{i=L}^{R} C[i]\).
  • The maximum number of coins collected in a single stage within that period.

Print the results for each query, with the sum and the maximum value separated by a space on a new line.

inputFormat

The input is read from stdin and has the following format:

  1. An integer N representing the number of stages.
  2. A line with N space separated integers, where each integer represents the coins collected in each stage.
  3. An integer Q representing the number of queries.
  4. Q lines follow, each containing two integers L and R denoting the range (inclusive) of stages for the query.

outputFormat

For each query, output a line with two integers separated by a space: the total coins collected in that period and the maximum coins in any single stage within that period. The output is printed to stdout.

## sample
6
10 20 30 40 50 60
1
1 3
60 30