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)$个无三点共线的点,问这些点组成了多少个锐角三角形. 分析:显然任意三点可构成三角形,而锐角三角形不如直角或钝角三角形容易计数,因为后者有且仅 ...
随机推荐
- 【2018百度之星资格赛】 A 问卷调查 - 位运算&动规
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6344 参考博客:在此感谢http://www.cnblogs.com/LQLlulu/p/941923 ...
- ubuntu14.04 fcitx安装
先卸载ibus sudo apt-get remove ibus (也可尝试不卸载ibus,直接安装fcitx) 添加源 sudo add-apt-repository ppa:fcitx-team/ ...
- Shiro-工作流程
[与Web集成] 1.Shiro 提供了与 Web 集成的支持,其通过一个ShiroFilter 入口来拦截需要安全控制的URL,然后进行相应的控制. 2.ShiroFilter 类似于如 Strut ...
- nyoj 4 ASCII码排序(set,multiset)
ASCII码排序 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符. 输入 第一行输 ...
- [luoguP1474] 货币系统 Money Systems(背包)
传送门 背包 ——代码 #include <cstdio> #include <iostream> #define LL long long int v, n; LL f[10 ...
- vim高亮显示当前行列
vim高亮显示当前行: set cursorline vim高亮显示当前列: set cursorcolumn
- [USACO09JAN]全流Total Flow
题目描述 Farmer John always wants his cows to have enough water and thus has made a map of the N (1 < ...
- Linux下汇编语言学习笔记77 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- Codeforces Round #403(div 2)
A =w= B 题意:一个数轴上有n个整点,每个点都有一个速度,选一个点让他们集合,使得时间最少. 分析: 直接三分 C 题意:给定一棵树,任意两个距离小等于二的点不能染相同的颜色,求最小颜色数和染色 ...
- [bzoj 1042][HAOI2008]硬币购物(用容斥原理弄背包)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1042 分析: 解法很巧妙,用f[i]表示四种硬币A.B.C.D的数量不考虑的情况下弄成 ...