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的更多相关文章

  1. ural1126 Magnetic Storms

    Magnetic Storms Time limit: 0.5 secondMemory limit: 64 MB The directory of our kindergarten decided ...

  2. 1126. Magnetic Storms(单调队列)

    1126 最简单的单调队列应用吧 单调队列是指在一个队列中各个元素单调 递增(或者递减),并且各个元素的下标单调 递增. 单调队列的大体操作 进队时,将进队的元素为e,从队尾往前扫描,直到找到一个不大 ...

  3. ural 1126 Magnetic Storms

    http://acm.timus.ru/problem.aspx?space=1&num=1126 #include <cstdio> #include <cstring&g ...

  4. 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 ...

  5. Transcranial magnetic stimulation (TMS)

    Transcranial magnetic stimulation (TMS) Effect of Transcranial Magnetic Stimulation on Free Will Tra ...

  6. MaLoc: a practical magnetic fingerprinting approach to indoor localization using smartphones

    https://www.indooratlas.com/ MaLoc: a practical magnetic fingerprinting approach to indoor localizat ...

  7. Magnetic Fingerprinting Approach to Indoor Localization

    Magnetic Fingerprinting Approach to Indoor Localization

  8. HearthBuddy Magnetic 磁力

    https://hearthstone.gamepedia.com/Magnetic Magnetic is an ability exclusive to certain Mech minions ...

  9. LA 4064 Magnetic Train Tracks

    题意:给定平面上$n(3\leq n \leq 1200)$个无三点共线的点,问这些点组成了多少个锐角三角形. 分析:显然任意三点可构成三角形,而锐角三角形不如直角或钝角三角形容易计数,因为后者有且仅 ...

随机推荐

  1. lombok无法解析log

    首先确认开发工具是否安装lombok,已安装的话打开lombok插件页,选择update, 然后重启idea.

  2. 洛谷——P1413 坚果保龄球

    P1413 坚果保龄球 题目描述 PVZ这款游戏中,有一种坚果保龄球.zombie从地图右侧不断出现,向左走,玩家需要从左侧滚动坚果来碾死他们. 我们可以认为地图是一个行数为6,列数为60的棋盘.zo ...

  3. 「 Luogu P1231 」 教辅的组成

    题目大意 有 $\text{N1}$ 本书 $\text{N2}$本练习册 $\text{N3}$本答案,一本书只能和一本练习册和一本答案配对.给你一些书和练习册,书和答案的可能的配对关系.问你最多可 ...

  4. Linux学习笔记记录(补充)

  5. linux tload-显示系统负载状况

    推荐:更多linux 性能监测与优化 关注:linux命令大全 tload命令以图形化的方式输出当前系统的平均负载到指定的终端.假设不给予终端机编号,则会在执行tload指令的终端机显示负载情形. 语 ...

  6. python爬虫23 | 手机,这次要让你上来自己动了。这就是 Appium+Python 的牛x之处

    你有没有想过让你的手机帮你自动完成某些事情 比如自动帮你抢红包 有些软件不是有签到活动么 这些傻瓜式的操作 能不能让手机自动签到呢? 自动帮你叫外卖 自动帮你打电话 等等 还有 对于手机上的一些比较难 ...

  7. 51nod1429 巧克力

    [题解] 找一下两个面积s1,s2的2和3的因子数,把他们除掉,如果s1,s2不相等,就是-1,否则可以用s1,s2的2和3的因子数计算答案. #include<cstdio> #incl ...

  8. java8 lambda 函数式编程

    package com.atguigu.java8; import java.util.ArrayList; import java.util.Comparator; import java.util ...

  9. JavaSE 学习笔记之Jdk5.0新特性(十九)

    Jdk5.0新特性: Collection在jdk1.5以后,有了一个父接口Iterable,这个接口的出现的将iterator方法进行抽取,提高了扩展性. --------------------- ...

  10. UVa - 12451 - Let's call SPaDe a SPaDe

    先上题目: Problem H: Let's call SPaDe a SPaDe Passing time, walking the passage, as you pass the String ...