[Huawei 2016 Computer Test Programming Questions] What is the highest score

Article Directory

topic

Insert picture description here
Insert picture description here

solution

注意点

不止输入一组n,m
Q后跟的两个数据A,B,可能A>B
while True:
    try:
        a, b = map(int, input().split())
        grades = list(map(int, input().split()))
        for i in range(b):
            command = input().split()
            if command[0] == "Q":
                start, end = sorted([int(command[1]), int(command[2])])
                print(max(grades[start - 1:end]))
            else: grades[int(command[1]) - 1] = int(command[2])
    except:
        break

Guess you like

Origin blog.csdn.net/weixin_39333120/article/details/110928132