hdu5443(2015长春赛区网络赛1007)暴力
题意:给了一个数列,有多个询问,每个询问求某个区间内的最大值
数列长度 1000,询问个数 1000,静态,并不需要RMQ这些,直接暴力 n2 查找每个询问区间取最大值就行了。
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
const int maxn=; int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} int a[maxn]; int main(){
int T;
scanf("%d",&T);
while(T--){
int n;
scanf("%d",&n);
for(int i=;i<=n;++i){
scanf("%d",&a[i]);
}
int q;
scanf("%d",&q);
while(q--){
int aa,b;
scanf("%d%d",&aa,&b);
int ans=-;
for(int i=aa;i<=b;++i)if(a[i]>ans)ans=a[i];
printf("%d\n",ans);
}
}
return ;
}
hdu5443(2015长春赛区网络赛1007)暴力的更多相关文章
- hdu 4272 2012长春赛区网络赛 dfs暴力 ***
		
总是T,以为要剪枝,后来发现加个map就行了 #include<cstdio> #include<iostream> #include<algorithm> #in ...
 - hdu5442(2015长春赛区网络赛1006)后缀数组+KMP /最小表示法?
		
题意:给定一个由小写字母组成的长度为 n 的字符串,首尾相连,可以从任意一个字符开始,顺时针或逆时针取这个串(长度为 n),求一个字典序最大的字符串的开始字符位置和顺时针或逆时针.如果有多个字典序最大 ...
 - hdu5441(2015长春赛区网络赛1005)类最小生成树、并查集
		
题意:有一张无向图,一些点之间有有权边,某条路径的值等于路径上所有边的边权的最大值,而某个点对的值为这两点间所有路径的值的最小值,给出多个询问,每个询问有一个值,询问有多少点对满足其值小于等于询问值. ...
 - hdu5438(2015长春赛区网络赛1002)拓扑序+DFS
		
题意:给出一张无向图,每个节点有各自的权值,问在点数为奇数的圈中的点的权值总和是多少. 通过拓扑序的做法标记出所有非圈上的点,做法就是加每条边的时候将两点的入度都加一,然后将所有度数为1的点入队,删去 ...
 - hdu 4274 2012长春赛区网络赛 树形dp ***
		
设定每个节点的上限和下限,之后向上更新,判断是否出现矛盾 #include<cstdio> #include<iostream> #include<algorithm&g ...
 - hdu 4277 2012长春赛区网络赛 dfs+hashmap ***
		
hashmap判重大法好 #include<cstdio> #include<iostream> #include<algorithm> #include<c ...
 - hdu 4273 2012长春赛区网络赛 三维凸包中心到最近面距离 ***
		
新模板 /* HDU 4273 Rescue 给一个三维凸包,求重心到表面的最短距离 模板题:三维凸包+多边形重心+点面距离 */ #include<stdio.h> #include&l ...
 - Largest Point (2015沈阳赛区网络赛水题)
		
Problem Description Given the sequence A with n integers t1,t2,⋯,tn. Given the integral coefficients ...
 - HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
		
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
 
随机推荐
- 关于Integer缓冲
			
默认的时候,-128--127范围内的数会被缓冲 但是jvm启动的时候可以修改启动参数-Djava.lang.Integer.IntegerCache.high=2000 来修改上限,但是下限是不可以 ...
 - English idioms
			
a hot potato : speak of an issue(mostly current) which many people are talking about and which is us ...
 - 1.6 suid/guid
			
1.很系统供应商不允许使用这一命令,或者即使被置位,也会被忽略,这一命令会带来安全性风险. suid意味着该用户对自己的shell脚本设置了这种权限,那么其他用户执行该脚本时,也将拥有该用户相同的权限 ...
 - [Unity3D]调用Android接口
			
简介 有一些手机功能,Unity没有提供相应的接口,例如震动,例如不锁屏,例如GPS,例如... 有太多的特殊功能Unity都没有提供接口,这时候,我们就需要通过使用Android原生的ADT编辑器去 ...
 - ImageLoder配置以及使用(个人阅读使用)
			
http://blog.csdn.net/vipzjyno1/article/details/23206387 在gradle添加: compile 'com.nostra13.universalim ...
 - 《Objiect》
			
[16-1]Object概述&Object-equals方法&toString方法. ================================================= ...
 - 自定义的BroadCastReceiver
			
1.MainActivity2.java中的代码,主要是使用意图发送广播 public class MainActivity2 extends Activity{ @Override protecte ...
 - Codeforces Round #247 (Div. 2)
			
A.水题. 遍历字符串对所给的对应数字求和即可. B.简单题. 对5个编号全排列,然后计算每种情况的高兴度,取最大值. C.dp. 设dp[n][is]表示对于k-trees边和等于n时,如果is== ...
 - java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
			
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
 - Smart210学习记录-------linux内核模块
			
Linux 驱动工程师需要牢固地掌握 Linux 内核的编译方法以为嵌入式系统构建可运行的Linux 操作系统映像.在编译 LDD6410 的内核时,需要配置内核,可以使用下面命令中的 一个: #ma ...