hdu 5443 The Water Problem

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int _,i,n,a[1024],m,r,l,ans;
    scanf("%d",&_);
    while(_--)
    {
        scanf("%d",&n);
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        scanf("%d",&m);
        for(i=0;i<m;i++)
        {
            scanf("%d%d",&r,&l);
            ans=-1;
            for(int j=r;j<=l;j++)
            {
                ans=max(ans,a[j]);
            }
            printf("%d
",ans);
        }
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

原文地址:https://www.cnblogs.com/xryz/p/4847777.html