Title Description:
The teacher wants to know from the so-and-so classmate, the highest score is how many, now asks you to program the simulation teacher's inquiry. Of course, teachers sometimes need to update a student's grades.
Input Description:
The input includes multiple sets of test data.
The first line of each set of inputs is two positive integers N and m (0 < N <= 30000,0 < M < 5000), representing the number of students and the number of operations respectively.
Student ID number from 1 to N.
The second line contains n integers representing the initial scores of the N students, where the number of I represents the student's score for ID i.
Next M-line, each line has a character C (only ' Q ' or ' U '), and two positive integers, a, B, when C is ' Q ', indicating that this is a query operation, he asked the ID from a to B (including A, a) among students, the highest performance is how much
When C is ' U ', it indicates that this is an update operation that requires the student with ID A to change the grade to B.
Output Description:
For each query operation, output the highest score in one line.
Input Example:
5 7
1 2 3) 4 5
Q 1 5
U 3 6
Q 3 4
Q 4 5
U 4 5
U 2 9
Q 1 5
Output Example:
5
6
5
9
Simple question, ac on the bull, the code is as follows:
1#include <stdio.h>2#include <iostream>3 using namespacestd;4 5 intMain ()6 {7 intm,n,score[30000];8 CharOper;9 while(Cin >> N >>M)Ten { One for(inti =0; i < N; ++i) A { -scanf"%d", score +i); - } the for(intj =0; J < M; ++j) - { - intA, B, Max; -CIN >> Oper >> A >>B; + if(Oper = ='Q') - { + if(A > N | | B >N) A { at return 0; - } - Else - { - if(A >B) - { in intTMP =A; -A =B; toB =tmp; + } -max = Score[a-1]; the for(intK = A; K < B; k++) * { $ if(Max <Score[k])Panax Notoginseng { -Max =Score[k]; the } + } Acout << Max <<Endl; the } + - } $ Else if(Oper = ='U') $ { - if(A >N) - { the return 0; - }Wuyi Else the { -Score[a-1] =B; Wu } - } About } $ } - return 0; -}
What's the highest score?