hdu 5443 The Water Problem(长春网络赛——暴力)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5443
The Water Problem
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.
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.
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
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(长春网络赛——暴力)的更多相关文章
- hdu 5443 The Water Problem
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Description In Land waterless, ...
- HDU 4768 Flyer (2013长春网络赛1010题,二分)
Flyer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu 5443 The Water Problem 线段树
The Water Problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- HDU 5443 The Water Problem (ST算法)
题目链接:HDU 5443 Problem Description In Land waterless, water is a very limited resource. People always ...
- 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 ...
- 【线段树】HDU 5443 The Water Problem
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5443 题目大意: T组数据.n个值,m个询问,求区间l到r里的最大值.(n,m<=1000) ...
- 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.......,最 ...
- HDU 5443 The Water Problem (水题,暴力)
题意:给定 n 个数,然后有 q 个询问,问你每个区间的最大值. 析:数据很小,直接暴力即可,不会超时,也可以用RMQ算法. 代码如下: #include <cstdio> #includ ...
- hdu 4762 && 2013 ACM/ICPC 长春网络赛解题报告
这次的答案是猜出来的,如果做得话应该是应该是一个几何概型的数学题: 答案就是:n/(m^(n-1)); 具体的证明过程: 1.首先枚举这M个点中的的两个端点,概率是:n*(n-1); 2.假设这个蛋糕 ...
随机推荐
- css实现九宫格
原理:浮动+margin负边距 示例代码: <!DOCTYPE html> <html lang="zh"> <head> <meta c ...
- js与jQuery方法对比
javascript与jQuery方法对比jquery对象转dom对象 // 方式一(推荐使用) $("input")[0] // 方式二 $("input" ...
- 增强基本选择器[selector_3.html]
增强基本选择器[selector_3.html] $("ul li:first") $("ul li:last") $("table tr:even& ...
- 探秘蓝牙隐藏API
上次讲解Android的蓝牙基本用法,这次讲得深入些,探讨下蓝牙方面的隐藏API.用过Android系统设置(Setting)的人都知道蓝牙搜索之后可以建立配对和解除配对,但是这两项功能的函数没有在S ...
- HTTP管线化技术--ajax请求
1.管线化技术——客户端可以发送多次请求到服务端,而不需要等待上一次请求得到响应的时候才能进行下一次请求.实现并行发送请求 2.ajax——实现网页异步刷新 问题:当用户进行多次ajax请求的时候,并 ...
- js--在页面元素上(移动到或获取焦点)、鼠标离开(或失去焦点)
1.onfocus() 和 onblur() 是一对相反的事件 但是他们只支持一部分标签 W3C关于onblur的描述:http://www.w3school.com.cn/jsref/event_o ...
- java中long型时间戳的计算
计算时间的时候碰到的问题: Date d = new Date(); long currtime = d.getTime(); //获取当前时间 long starttime = currtime - ...
- atitit。解决 No suitable Log constructor。。NoClassDefFoundError: org/apache/log4j/Category 找不到类的
atitit.解决 No suitable Log constructor..NoClassDefFoundError: org/apache/log4j/Category 找不到类的 1. 深的层次 ...
- Java常量池解析与字符串intern简介
在Java应用程序运行时,Java虚拟机会保存一份内部的运行时常量池,它区别于class文件的常量池,是class文件常量池映射到虚拟机中的数据结构. 关于class文件常量池的部分可以参考之前的博文 ...
- iOS应用代码段瘦身办法
iOS应用代码段瘦身办法 大型app应对苹果官方代码段大小限制的小伎俩… 背景 苹果官方文档 对二进制 __TEXT 段大小有限制: 代码实在瘦不下去怎么办? 解决方案 利用 rename_secti ...