# 华为机试：最高分是多少

xiaoxiao2021-02-28  62

import java.util.ArrayList; import java.util.Scanner; public class highestScore { public static void main(String[] args) { // ArrayList<Integer> arrayList = new ArrayList<>(); Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { String line = scanner.nextLine(); String[] firstStr = line.split("\\s"); int N =Integer.parseInt(firstStr[0]) ; int M = Integer.parseInt(firstStr[1]); line = scanner.nextLine(); String[] grade = line.split("\\s"); int[] grades = new int[N]; for (int i = 0; i < N; i++) { grades[i] = Integer.parseInt(grade[i]); } for (int i = 0; i < M; i++) { String mString = scanner.nextLine(); String[] strings = mString.split("\\s"); String C = strings[0]; int A = Integer.parseInt(strings[1]); int B = Integer.parseInt(strings[2]); if (C.equals("Q")) { int maxValue = max(grades,A,B); System.out.println(maxValue); }else if (C.equals("U")) { upDateGrade(grades, A,B); } } } } private static void upDateGrade(int[] arr,int a, int b) { //更新操作 arr[a-1] = b; } private static int max(int[] arr,int a, int b) { //最大值 int temp = a; if (a>b) { a=b; b=temp; } int max = arr[a-1]; for (int i = a-1; i < b; i++) { if (arr[i]>max) { max= arr[i]; } } return max; } }