博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #305 (Div. 2) D. Mike and Feet
阅读量:7079 次
发布时间:2019-06-28

本文共 1586 字,大约阅读时间需要 5 分钟。

D. Mike and Feet
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.

A group of bears is a non-empty contiguous segment of the line. The size of a group is the number of bears in that group. The strength of a group is the minimum height of the bear in that group.

Mike is a curious to know for each x such that 1 ≤ x ≤ n the maximum strength among all groups of size x.

Input

The first line of input contains integer n (1 ≤ n ≤ 2 × 105), the number of bears.

The second line contains n integers separated by space, a1, a2, ..., an (1 ≤ ai ≤ 109), heights of bears.

Output

Print n integers in one line. For each x from 1 to n, print the maximum strength among all groups of size x.

Examples
input
10 1 2 3 4 5 4 3 2 1 6
output
6 4 4 3 3 2 2 1 1 1 学些数据结构才可以拯救自己吧,数据结构是省时的好东西哦,本来n^2可以变为nlgn甚至n,简直爆炸,单调栈就算能把复杂程度降到n的,太强辣,强行学习一波 其实我只是为了做出我们平台那道题,大佬讲让我用单调栈类似物,但是我并不了解这种数据结构啊,先mark下
#include 
using namespace std;const int N=2e5+5;struct node{ int L, num;}S;stack
sta;int a[N], ans[N];int main (){ int n; while (scanf ("%d", &n) != EOF) { for (int i=0; i
=1; i--) ans[i] = max (ans[i], ans[i+1]); for (int i=1; i
View Code

 

转载于:https://www.cnblogs.com/BobHuang/p/6826638.html

你可能感兴趣的文章
eclipse里maven项目An error occurred while filtering resources解决办法
查看>>
MySQL导入SQL文件及常用命令
查看>>
Can't locate find.pl in @INC (@INC contains: /etc/perl xxxx) at perlpath.pl line 7.
查看>>
c#(.Net)解析xml
查看>>
调整Virtual Box硬盘大小
查看>>
阻塞和非阻塞,同步和异步 总结【转】
查看>>
社会实体经济不断下滑的个人思考
查看>>
Pytorch多GPU并行处理
查看>>
【定制Android系统】Android O 在ROM中添加自己的 so 库(1)——Android.mk 与 Android.bp 的区别【转】...
查看>>
C#中把货币、日期转换成中文大写
查看>>
最近累死人的校园招聘20110928
查看>>
数字信号处理实验(零)—— 一维声音信号处理和二维图像处理
查看>>
HTTP请求:GET与POST方法的区别
查看>>
使用CDN对动态网站内容加速有效果吗
查看>>
iOS -view横向变成竖向
查看>>
控件自定义
查看>>
[LeetCode] Sort Colors
查看>>
Hadoop集群datanode磁盘不均衡的解决方案
查看>>
SQL SERVER 中日期格式化,及GETDATE()、CONVERT()函数使用说明
查看>>
datasnap回调
查看>>