#K73722. Gameplay Analysis
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:
- An integer N representing the number of stages.
- A line with N space separated integers, where each integer represents the coins collected in each stage.
- An integer Q representing the number of queries.
- 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.
## sample6
10 20 30 40 50 60
1
1 3
60 30