题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5443

The Water Problem

Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 1084    Accepted Submission(s): 863
Problem Description
In Land waterless, water is a very limited resource. People always fight for the biggest source of water. Given a sequence of water sources with a1,a2,a3,...,anrepresenting
the size of the water source. Given a set of queries each containing 2 integers l and r,
please find out the biggest water source between al and ar.
 
Input
First you are given an integer T(T≤10) indicating
the number of test cases. For each test case, there is a number n(0≤n≤1000) on
a line representing the number of water sources. n integers
follow, respectively a1,a2,a3,...,an,
and each integer is in {1,...,106}.
On the next line, there is a number q(0≤q≤1000) representing
the number of queries. After that, there will be q lines
with two integers l and r(1≤l≤r≤n) indicating
the range of which you should find out the biggest water source.
 
Output
For each query, output an integer representing the size of the biggest water source.
 
Sample Input
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
 
Sample Output
100
2
3
4
4
5
1
999999
999999
1
 
Source
 
Recommend
hujie   |   We have carefully selected several similar problems for you:  5664 

pid=5663" style="color:rgb(26,92,200); text-decoration:none">5663 5662 5661 5660 

 

题目大意:给出n个水池的水量,找出区间内最大的水量。

求区间最值。正常都採用线段树的方法。可是这题数据量不大。全部暴力就过了~

详见代码。

#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(长春网络赛——暴力)的更多相关文章

  1. hdu 5443 The Water Problem

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Description In Land waterless, ...

  2. HDU 4768 Flyer (2013长春网络赛1010题,二分)

    Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  3. hdu 5443 The Water Problem 线段树

    The Water Problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  4. HDU 5443 The Water Problem (ST算法)

    题目链接:HDU 5443 Problem Description In Land waterless, water is a very limited resource. People always ...

  5. ACM学习历程—HDU 5443 The Water Problem(RMQ)(2015长春网赛1007题)

    Problem Description In Land waterless, water is a very limited resource. People always fight for the ...

  6. 【线段树】HDU 5443 The Water Problem

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5443 题目大意: T组数据.n个值,m个询问,求区间l到r里的最大值.(n,m<=1000) ...

  7. Hdu 5439 Aggregated Counting (2015长春网络赛 ACM/ICPC Asia Regional Changchun Online 找规律)

    题目链接: Hdu 5439 Aggregated Counting 题目描述: 刚开始给一个1,序列a是由a[i]个i组成,最后1就变成了1,2,2,3,3,4,4,4,5,5,5.......,最 ...

  8. HDU 5443 The Water Problem (水题,暴力)

    题意:给定 n 个数,然后有 q 个询问,问你每个区间的最大值. 析:数据很小,直接暴力即可,不会超时,也可以用RMQ算法. 代码如下: #include <cstdio> #includ ...

  9. hdu 4762 && 2013 ACM/ICPC 长春网络赛解题报告

    这次的答案是猜出来的,如果做得话应该是应该是一个几何概型的数学题: 答案就是:n/(m^(n-1)); 具体的证明过程: 1.首先枚举这M个点中的的两个端点,概率是:n*(n-1); 2.假设这个蛋糕 ...

随机推荐

  1. 关于android的设备管理器-DevicePolicyManager(二)

    上回分析到了/data/system/device_policies.xml这个文件是在package change事件发生的时候变化的.那么来看看它的内容. 依据以往的经验.在/data/syste ...

  2. MySQL数据库和实例简介

    MySQL 单进程多线程,也就是说MySQL实例在系统上表现就是一个进程 该架构类似于SQL Server和Windows版本的Oracle MySQL数据库是由一些列物理文件组成.类似于frm.MY ...

  3. 〖Linux〗(2013.08.02)VIM74b+YouCompleteMe,VIM代码编辑器补全能手

    1. 编译和安装vim74b(参考:http://t.cn/zQa8R7h ) sudo apt-get install -y hgsvn libncurses5-dev libgnome2-dev ...

  4. android源码如何起步与阅读方法

    显然Eclipse不是阅读Android源码的好工具,不流畅,搜索低效,继承性关系/调用关系都无法有效查看.推荐Source Insight,在这个工具帮助下,你才可以驾驭巨大数量的Android 源 ...

  5. Prototype的深度探索

    http://www.cnblogs.com/meil/archive/2007/06/06/773645.html 1 什么是prototype JavaScript中对象的prototype属性, ...

  6. HDU 4280Island Transport(网络流之最大流)

    题目地址:pid=4280">http://acm.hdu.edu.cn/showproblem.php? pid=4280 这个题是一个纯最大流模板题..就是用来卡时间的.. 还好我 ...

  7. C++二维数组讲解、二维数组的声明和初始化

    我们知道,一维空间是一条线,数学中用一条数轴来表达:二维空间是一个平面,数学中用平面坐标系来表达.那么二维数组又是什么样的呢? 线与面 我们用一个下标来描述一维数组中的某个元素,就好像在用数描述一条线 ...

  8. export、exports、modules.exports 和 require 、import 的一些组合套路和坑

    推荐阅读第三方文章: http://www.tuicool.com/articles/uuUVBv2 引入: require / import 导出:export / module.exports / ...

  9. ov5640 video capture时,vfe_v4l2.ko模块挂掉问题分析

    1.问题描述 在r16 tina平台,基于ov5640获取摄像头数据时,vfe_v4l2.ko模块挂掉. 2.配置信息 2.1上层应用设置的像素格式为V4L2_PIX_FMT_YUYV,分辨率为480 ...

  10. wifi免密码登录认证流程

    您查询的关键词是:weixin:,qrgex_zm- 以下是该网页在北京时间 2016年03月27日 02:46:42 的快照: 如果打开速度慢,可以尝试快速版:如果想保存快照,可以添加到搜藏:如果想 ...