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.假设这个蛋糕 ...
随机推荐
- 算法笔记_128:完美洗牌算法(Java)
目录 1 问题描述 2 解决方案 2.1位置置换算法 2.2 走环算法 1 问题描述 有一个长度为2n的数组{a1,a2,a3,...,an,b1,b2,b3,...,bn},希望排序后变成{a1 ...
- jQuery中.html(“xxx”)和.append("xxx")的区别和不同
append是追加,html是完全替换比如<p id="1"><p>123</p></p>$("#1").htm ...
- 2、JSP脚本
JSP脚本 JSP脚本包含了JSP表达式.声明标识和脚本程序.通过这些标识,在JSP页面中可以如同编写Java程序一样来声明变量.定义方法和执行各种表达式的运算 1.在JSP中应用代码片段 语法格式: ...
- 【APP接口开发】常用HTTP响应头状态码详解
1.200 OK,客户端请求城成功 2.400 Bad Request ,客服端请求语法错误,服务器无法理解和处理 3.401 unauthorized,请求未通过认证 4.403 permissio ...
- 【LeetCode】106. Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of ...
- 【LeetCode】117. Populating Next Right Pointers in Each Node II (2 solutions)
Populating Next Right Pointers in Each Node II Follow up for problem "Populating Next Right Poi ...
- SQL 横转竖 、竖专横 (转载) 使用Dapper.Contrib 开发.net core程序,兼容多种数据库 C# 读取PDF多级书签 Json.net日期格式化设置 ASPNET 下载共享文件 ASPNET 文件批量下载 递归,循环,尾递归 利用IDisposable接口构建包含非托管资源对象 《.NET 进阶指南》读书笔记2------定义不可改变类型
SQL 横转竖 .竖专横 (转载) 普通行列转换 问题:假设有张学生成绩表(tb)如下: 姓名 课程 分数 张三 语文 74 张三 数学 83 张三 物理 93 李四 语文 74 李四 数学 84 ...
- 关注C++细节——C++11新标准之decltype的使用注意
c++11新特性--decltype decltype是C++11加入的一个新的keyword,目的是选择并返回操作数的数据类型,重要的是,在此过程中编译器分析表达式并得到它的类型,却不实际计算表达式 ...
- ORID方法在敏捷中的利用
Objective: 上个迭代有哪些让你印象深刻的事情发生?你看到了什么? Reflective:哪些场景让你兴奋?哪些地方不那么顺利? Interpretive:为什么会不顺利?这些数据使你意识到了 ...
- drawer navigation, tabhostFragment 默认导向
问题: 项目结构,在一个抽屉导航中的第一个抽屉中加入了一个tabHostFragment,每次进入项目都是在抽屉导航的默认界面,须要把抽屉划出来再选择某个抽屉. 可是想让APP直接跳转到第一个抽屉界面 ...