Magnetic Storms

Time limit: 0.5 second
Memory limit: 64 MB
The directory of our kindergarten decided to be attentive to the children's health and not to let them walk outdoors during magnetic storms. Special devices that measure and display magnetic intensity were ordered. If the readout exceeded some certain level the children were told to go indoors. They disliked it because they couldn't play their games up to the end. The nannies hated it because they had to dress and undress children many times.
After a while it became clear that one could try to forecast magnetic intensity because long periods of quietude alternated with short periods of plenty of sharp peaks (this is called a magnetic storm). Hence a new modification of the devices was ordered.
The new devices were to remember the situation within several last hours and to display the maximal intensity during the period. If the intensity was low within the last 6 hours the magnetic field was regarded to be quiet; the children were let outdoors and played all the prescript time. Otherwise new peaks were probable and the children spent their time indoors.
Your task is to write a program for a new version of the device. As a matter of fact you are to solve just the main problem of modification. All the rest is already done.
You are given a number M which is length of a period (in seconds) within which peaks are to be stored and displayed. A sequence of measured magnetic intensity values is given to you as well. Each measurement is a number within the range from 0 to 100000.
Your are to output a sequence of values displayed by the device. The first number of the sequence is the maximal element of the first M input numbers, the second number is the maximal element of the 2nd, …, M+1-st input numbers and so on.
We hope that the new devices with your program won't go back on nannies and children will not walk during magnetic storms.

Input

The first line contains a number M, 2 ≤ M ≤ 14000. Then values (N integers) measured by the device follow each one in its line. There is a number −1 in the end. M ≤ N ≤ 25000.

Output

a sequence of readouts, each one in its line.

Sample

input output
3
10
11
10
0
0
0
1
2
3
2
-1
11
11
10
0
1
2
3
3

分析:可以水过;

代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e5+;
const int dis[][]={{,},{-,},{,-},{,}};
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
int n,m,k,t,a[maxn],coco[maxn];
priority_queue<int>p;
int main()
{
int i,j;
scanf("%d",&n);
while(scanf("%d",&a[m++])&&a[m-]!=-);
m--;
for(int i=;i<=m-n;i++)printf("%d\n",*max_element(a+i,a+i+n));
//system("pause");
return ;
}

ural1126 Magnetic Storms的更多相关文章

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

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

  2. ural 1126 Magnetic Storms

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

  3. Magnetic Storms

    http://acm.timus.ru/problem.aspx?space=1&num=1126 简单的线段树求区间最值 #include <stdio.h> #include ...

  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. iOS使用NSMutableAttributedString

    在iOS开发中,常常会有一段文字显示不同的颜色和字体,或者给某几个文字加删除线或下划线的需求.之前在网上找了一些资料,有的是重绘UILabel的textLayer,有的是用html5实现的,都比较麻烦 ...

  2. mysql开启/关闭 update delete 安全模式

    在使用mysql执行update的时候,如果不是用主键当where语句,会报如下错误,使用主键用于where语句中正常. 异常内容:Error Code: 1175. You are using sa ...

  3. iwlist等工具的移植

    http://blog.csdn.net/jk110333/article/details/8658054 参考了这边文章 -------------------------------------- ...

  4. C#中使用正则表达式提取超链接地址的集中方法

    一般在做爬虫或者CMS的时候经常需要提取 href链接或者是src地址.此时可以使用正则表达式轻松完成. Regex reg = new Regex(@"(?is)<a[^>]* ...

  5. ibatis resultMap 结果集映射

    1.结果集映射 就是将返回的记录,逐个字段映射到java对象上:如果数据库字段与java对象的成员变量名对应的话,则使用resultClas即可 2.实现 结合 ibatis初探这篇文章中提到的pro ...

  6. iframe子页面调用父页面javascript函数的方法

    1.iframe子页面调用 父页面js函数 子页面调用父页面函数只需要写上window.parent就可以了.比如调用a()函数,就写成: window.parent.a(); 2.iframe父页面 ...

  7. WPF中静态引用资源与动态引用资源的区别

    WPF中静态引用资源与动态引用资源的区别   WPF中引用资源分为静态引用与动态引用,两者的区别在哪里呢?我们通过一个小的例子来理解. 点击“Update”按钮,第2个按钮的文字会变成“更上一层楼”, ...

  8. php 四种基础的算法 ---- 冒泡排序法

    1. 冒泡排序法  *     思路分析:法如其名,就是像冒泡一样,每次从数组当中 冒一个最大的数出来.  *     比如:2,4,1    // 第一次 冒出的泡是4  *             ...

  9. gSoap客户端示例程序

    先给出wsdl2h和soapcpp2的生成客户端代码 wsdl2h -s -o calc.h http://www.genivia.com/calc.wsdl soapcpp2 -i -C -x -I ...

  10. Java中常见的5种WEB服务器介绍

    这篇文章主要介绍了Java中常见的5种WEB服务器介绍,它们分别是Tomcat.Resin.JBoss.WebSphere.WebLogic,需要的朋友可以参考下 Web服务器是运行及发布Web应用的 ...