2 条题解

  • 1
    @ 2021-11-14 12:09:10

    不想整一次循环了,反正也是基础题

    #include<iostream> 
    using namespace std; 
    int n,a[1005],m,l,r,maxx=-1;
    int main(){
    	cin >> n;
        for(int i = 1; i <= n; i++)
            cin >> a[i];
        cin >> m;
        for(int i = 1; i <= m; i++){
            cin >> l >> r;
            for(;l <= r; l++)
                if(a[l] > maxx) maxx = a[l];
            cout << maxx << endl;
            maxx = -1;
        }
        return 0;
    }
    

    信息

    ID
    1420
    时间
    1000ms
    内存
    128MiB
    难度
    9
    标签
    递交数
    9
    已通过
    7
    上传者