Magnetic Storms
http://acm.timus.ru/problem.aspx?space=1&num=1126
简单的线段树求区间最值
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N=;
int a[N],ans ;
struct node
{
int l,r,Max;
} tree[N*];
void build(int t,int l,int r)
{
tree[t].l = l;
tree[t].r = r;
if (l==r)
{
tree[t].Max = a[r];
return ;
}
int mid = (l+r)>>;
build(t<<,l,mid);
build(t<<|,mid+,r);
tree[t].Max = max(tree[t<<].Max,tree[t<<|].Max);
}
void Query(int t,int l,int r)
{
if (l <= tree[t].l && r>= tree[t].r)
{
ans = max(ans,tree[t].Max);
return ;
}
int mid = (tree[t].l+tree[t].r)>>;
if (r <= mid)
Query(t<<,l,r);
else if (l > mid)
Query(t<<|,l,r);
else
{
Query(t<<,l,mid);
Query(t<<|,mid+,r);
}
}
int main()
{
int m,n = ,x;
scanf("%d",&m);
while()
{
scanf("%d",&x);
if (x == -)
break;
a[n++] = x;
}
build(,,n);
for (int i = ; i <= n-m; i++)
{
ans = ;
Query(,i,m+i-);
printf("%d\n",ans);
}
return ;
}
Magnetic Storms的更多相关文章
- ural1126 Magnetic Storms
Magnetic Storms Time limit: 0.5 secondMemory limit: 64 MB The directory of our kindergarten decided ...
- 1126. Magnetic Storms(单调队列)
1126 最简单的单调队列应用吧 单调队列是指在一个队列中各个元素单调 递增(或者递减),并且各个元素的下标单调 递增. 单调队列的大体操作 进队时,将进队的元素为e,从队尾往前扫描,直到找到一个不大 ...
- ural 1126 Magnetic Storms
http://acm.timus.ru/problem.aspx?space=1&num=1126 #include <cstdio> #include <cstring&g ...
- NOTES : A Model of Gas Exchange for Hyperpolarized Xe(129) Magnetic Resonance of the Lung
NOTES : A Model of Gas Exchange for Hyperpolarized Xe(129) Magnetic Resonance of the Lung 背景知识: Ga ...
- Transcranial magnetic stimulation (TMS)
Transcranial magnetic stimulation (TMS) Effect of Transcranial Magnetic Stimulation on Free Will Tra ...
- MaLoc: a practical magnetic fingerprinting approach to indoor localization using smartphones
https://www.indooratlas.com/ MaLoc: a practical magnetic fingerprinting approach to indoor localizat ...
- Magnetic Fingerprinting Approach to Indoor Localization
Magnetic Fingerprinting Approach to Indoor Localization
- HearthBuddy Magnetic 磁力
https://hearthstone.gamepedia.com/Magnetic Magnetic is an ability exclusive to certain Mech minions ...
- LA 4064 Magnetic Train Tracks
题意:给定平面上$n(3\leq n \leq 1200)$个无三点共线的点,问这些点组成了多少个锐角三角形. 分析:显然任意三点可构成三角形,而锐角三角形不如直角或钝角三角形容易计数,因为后者有且仅 ...
随机推荐
- struts2源码下载链接
http://blog.csdn.net/qq_qun_247286682/article/details/6975298
- Go:条件语句、循环语句
一.条件语句 package main import ( "fmt" "io/ioutil" ) // if的条件不需要括号 func xx(i int) in ...
- linux命令 info
info命令是Linux下info格式的帮助指令. 就内容来说,info页面比man page编写得要更好.更容易理解,也更友好,但man page使用起来确实要更容易得多.一个man page只有一 ...
- MAC上postman离线安装时提示加载扩展程序出错怎么办?
目前的postman插件如果想正常使用,必须安装Postman Interceptor插件,这样才能直接使用chrome浏览器的cookie等信息,否则postman是无法完成老版本的功能的.post ...
- 文件内容差异对比-python
上次没精力时候,看了下python自动化运维,给print加了颜色,新鲜哒 今天来写写文件对比 step1:引入difflib库(无需安装,python自带) step2:将文件内容按行分割,spli ...
- pandas文本处理
import pandas as pd import numpy as np s = pd.Series([', np.nan, 'hj']) df = pd.DataFrame({'key1': l ...
- calculate Cp history (from Fluent) using Matlab
input data : unscaled time history of moment/thrust from ANSYS fluent example of input data, "m ...
- 洛谷 2434 [SDOI2005]区间
[题解] 鲜活的大水题... 把区间排个序然后瞎搞就可以了,发现现在区间的左端点比之前区间的最大的右端点还大,那就增加一个答案区间.每次更新目前最大右区间. #include<cstdio> ...
- 九度oj 题目1059:abc
题目1059:abc 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4510 解决:3546 题目描述: 设a.b.c均是0到9之间的数字,abc.bcc是两个三位数,且有:abc+bcc ...
- Android第三方开源SwitchButton
Android第三方开源SwitchButton Android SwitchButton是github上的一个第三方开源项目,其项目主页是:https://github.com/kyleduo/Sw ...