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.假设这个蛋糕 ...
随机推荐
- QtGui.QLineEdit
A QtGui.QLineEdit is a widget that allows to enter and edit a single line of plain text. There are u ...
- Java设计模式(二)-单例模式
单例模式建议保证某个对象仅仅仅仅有一个实例,当仅仅有一个对象来协调整个系统的操作时,在计算机系统中.线程池.缓存.日志对象.对话框.打印机.显卡的驱动程序对象常被设计成单例.总之,选择单例模式就是为了 ...
- JDBC 增删改查代码 过滤查询语句
package test; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; i ...
- LDAP 中 CN,OU,DC 的含意
CN, OU, DC 都是 LDAP 连接服务器的端字符串中的区别名称(DN, Distinguished Name) LDAP连接服务器的连接字串格式为:ldap://servername/DN ...
- 笔记本装ubuntu发热量大该如何缓解?
win7下的双卡技术是optimus, 驱动完善,不会让两个显卡同时满负荷工作, linux下由于驱动软件闭源, xorg的开源驱动没有做这个显卡电源管理, 目前的N卡较好解决方案就是bumblebe ...
- visio扩大画布的大小
鼠标移到画布的边界按住Ctrl,即可扩大画布的大小
- ASIHTTPRequest 简单使用
ASIHTTPResquest 框架功能强大,应用非常多. 曾经写过ASIHTTPResquest的导入,如今就看一下基本使用 记一下当中基础的操作: 1.发送同步请求: NSURL * url = ...
- C#基础—不安全代码(unsafe code)
1.为何要有unsafe 也许是为了实现CLR类型安全的目标吧,默认情况下,C#没有提供指针的使用算法,但是有些情况下也可能需要指针这样直接访问内存的东西(虽然目前我还没有用过),但是有时候程序员非常 ...
- 温度测量【RTD】
原理 温度是表征物体冷热程度的物理量,它可以通过物体随温度变化的某些特性(如电阻.电压变化等特性)来间接测量,通过研究发现,金属铂(Pt) 的阻值跟温度的变化成正比,并且具有很好的重现性和稳定性,利用 ...
- maple minimax函数
numapprox[minimax] - minimax rational approximation Calling Sequence minimax(f, x=a..b, [m, n], w, ...