#K4431. Student Score Queries
Student Score Queries
Student Score Queries
You are given the scores of ( n ) students and ( q ) operations. Each operation is of one of the following types:
- Update the score of the student at a given index to a new value.
- Query the maximum score in the range between two given indices.
For an update operation, the input is formatted as:
1 i x
which sets the score of the ( i^{th} ) student to ( x ). The query operation is formatted as:
2 l r
which requires you to output the maximum score in the range from index ( l ) to index ( r ). Formally, the query asks for the computation of:
[ \max{ s_i : l \le i \le r } ]
Your task is to process all operations sequentially and output the result of each query operation on a separate line. The input is read from standard input and the output should be printed to standard output.
inputFormat
The first line contains two integers ( n ) and ( q ), where ( n ) is the number of students and ( q ) is the number of operations. The second line contains ( n ) integers representing the initial scores of the students. The next ( q ) lines each describe an operation. Each operation is in one of the following formats:
- For an update operation:
1 i x
where ( i ) (1-indexed) is the student index and ( x ) is the new score. - For a query operation:
2 l r
where ( l ) and ( r ) (1-indexed) specify the inclusive range for the query.
outputFormat
For each query operation, output a single integer which is the maximum score in the specified range. Each result should be printed on a new line.## sample
5 5
1 2 3 4 5
2 1 3
1 3 6
2 2 4
1 5 1
2 3 5
3
6
6
</p>