标签:other should color str range sources orm uri float
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5443
3 1 100 1 1 1 5 1 2 3 4 5 5 1 2 1 3 2 4 3 4 3 5 3 1 999999 1 4 1 1 1 2 2 3 3 3
100 2 3 4 4 5 1 999999 999999 1
求区间最值。正常都採用线段树的方法。可是这题数据量不大。全部暴力就过了~
详见代码。
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int t;
int a[1010],l,r;
scanf("%d",&t);
while (t--)
{
int n;
scanf("%d",&n);
for (int i=1; i<=n; i++)
{
scanf("%d",&a[i]);
}
int q;
scanf("%d",&q);
while (q--)
{
int Max=0;
scanf("%d%d",&l,&r);
for (int i=l; i<=r; i++)
{
if (a[i]>Max)
Max=a[i];
}
cout<<Max<<endl;
}
}
return 0;
}hdu 5443 The Water Problem(长春网络赛——暴力)
标签:other should color str range sources orm uri float
原文地址:http://www.cnblogs.com/tlnshuju/p/7290074.html