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 ...
随机推荐
- Program L 暴力求解
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...
- [windows操作系统]windows模块
smss.exe csrss.exe Client/Server Runtime Server Subsystem
- App Store--心酸的上线路,说说那些不可思议的被拒理由
yoyeayoyea 您的应用包括色情内容(色情交易,色情展示). 原因是我们的销售人员,把几张艺术照放在个人相册里(头像),换成卡通头像,通过. 颜小风 被拒很正常 一次通过不正常. 之前上线 ...
- xcode 5.0 以上去掉icon高亮方法&iOS5白图标问题
之前的建议方法是把在xxx.info.plist文件中把 icon already includes gloss and bevel effects 设置YES 在Xcode5下,反复实现不成功,今天 ...
- CSS 3D旋转 hover 后设置transform 是相对于正常位置
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 针对初学者的A*算法入门详解(附带Java源码)
英文题目,汉语内容,有点挂羊头卖狗肉的嫌疑,不过请不要打击我这颗想学好英语的心.当了班主任我才发现大一18本书,11本是英语的,能多用两句英语就多用,个人认为这样也是积累的一种方法. Thanks o ...
- hdu 2000
ps:刚开始学C++...用C++来试试.. 代码: #include <iostream> using namespace std; int main(){ ],t,i,j; ]> ...
- jsp MVC学习笔记
Model层: 四个包: com.maker.bean存放数据库里面的字段信息. package com.maker.bean; public class User { private String ...
- 在国内时,更新ADT时需要配置的
RT
- Java Proxy
Client---->Interface A -- -- 代理类 Class AImpl 代理类是动态生成的,借助Proxy类和InvocationHandler接口进行实 ...