#C10349. Employee Performance Queries

    ID: 39544 Type: Default 1000ms 256MiB

Employee Performance Queries

Employee Performance Queries

You are given \( N \) employees. Each employee has a list of daily performance scores. Then, you are provided with \( Q \) queries. Each query consists of two integers \( A \) and \( B \) (1-indexed) representing the range of days.

For each query, determine the maximum performance score for each employee between days \( A \) and \( B \) (inclusive).

The problem can be formulated as follows: for each employee with scores array \(S = [s_1, s_2, \dots, s_T]\) and a query \( (A, B) \), compute \(\max\{s_A, s_{A+1}, \dots, s_B\}\).

inputFormat

The input is given via standard input (stdin) with the following format:

N
T1 score1 score2 ... scoreT1
T2 score1 score2 ... scoreT2
... (for N employees)
Q
A1 B1
A2 B2
... (for Q queries)

Where:

  • \( N \) is the number of employees.
  • For each employee, the first integer \( T \) denotes the number of days, followed by \( T \) integers representing daily performance scores.
  • \( Q \) is the number of queries.
  • Each query is represented by two integers \( A \) and \( B \) (with 1-indexing).

outputFormat

For each query, output a single line containing the maximum performance scores for each employee (in the same order as input) over the queried range \( [A, B] \). The scores should be separated by a space.

## sample
1
5 10 5 8 6 7
1
1 3
10

</p>