最高分多少问题(华为2016)

来源:互联网 发布:spss数据分析培训 编辑:程序博客网 时间:2024/05/22 00:38
#include<iostream>//#include <stdio.h>#include <algorithm>using namespace std; const int MAXN=100000; int data[MAXN+5]; int querymax ( int l , int r ) {    int ans=data[l];    for(int i=l+1;i<=r;i++)     {ans=max(ans,data[i]);}return ans;} void update(int idx,int value){    data[idx]=value;} int main(){    int n,m;    while(cin>>n>>m){        for(int i=1;i<=n;i++){            cin>>data[i];        }        char order;        int a,b;        for(;m--;){            cin>>order>>a>>b;if(a>n || b)            if(order=='U'){                update(a,b);            }else if(order=='Q'){                if(a>b) swap(a,b);                int ans = querymax(a,b);cout<<ans<<endl;            }        }    }    return 0;}

0 0
原创粉丝点击