"Huawei 2016 on-machine question C + +" What is the highest score?

Source: Internet
Author: User

What is the highest score of [programming question]?

Time limit: 1 seconds

Space limit: 65536K

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 ID is the result of the 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 an inquiry operation, He asked about the number of students whose IDs were from A to B (including A, a), and the highest scores were when C was ' U ', indicating that it was an update operation that required the students with ID A to change their grades to B.


Output Description:
For each query operation, output the highest score in one line.

Input Example:
5 2 3 4 5Q 1 5U 3 6Q 3 4Q 4 5U 4 5U 2 9Q 1 5

Output Example:
5659
1#include <iostream>2#include <vector>3 using namespacestd;4 5 intGetmax (vector<int> &gra,intXintY//Select the maximum value from X to Y6  {    7        inttemp;8        if(x>y)//consider entering the previous larger case than the following9        {Tentemp=x; Onex=y; Ay=temp;  -                   -        } the        intMax; -max=Gra[x]; -         for(inti=x;i<=y;++i) -        {            +             if(gra[i]>max) -max=Gra[i]; +             A        } at      -     returnMax; -      - } -  - intMain () in  { -       intx, y; to       Charch; +       intTemp,g_num,op_num; -vector<int>Max; the      *Cin>>g_num>>Op_num; $vector<int>GRA; Panax Notoginseng     -        for(intI=0; i<g_num;i++) the      { +Cin>>temp; A Gra.push_back (temp); the            +       } -      $       while(op_num--) $      { -           -Cin>>ch>>x>>y; the           -             if(ch=='Q')Wuyi             { the                  if(x==y) -                  { WuMax.push_back (gra[x-1]);  -                       About                  } $Max.push_back (Getmax (gra,x-1, Y1));  -                   -              } -              Else if(ch=='U') A              { +gra[x-1]=y; the              }                     -                    $           the      } the       for(vector<int>::iterator it = Max.begin (); It < Max.end (); it++) the       { thecout<<*it<<Endl; -        } in      the max.clear (); the         About     return 0; the      the}

"Huawei 2016 on-machine question C + +" What is the highest score?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.