Codeforces - Mike and Feet
题目链接:Mike and Feet
其实这道题也可以对每个点做单调栈,找到最为最小值的时候最大的区间。然做一个后缀max即可。
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=2e5+10;
int n,res[N],now,pos;
struct node{int ls,rs,s;}t[N<<2],c;
struct query{int id,a;}q[N];
#define mid (l+r>>1)
inline node merge(node a,node b,int ll,int rr){if(a.ls==ll) c.ls=ll+b.ls;else c.ls=a.ls;if(b.rs==rr) c.rs=rr+a.rs;else c.rs=b.rs;c.s=max(a.s,b.s);if(a.rs&&b.ls) c.s=max(c.s,a.rs+b.ls);return c;
}
void change(int p,int l,int r,int x){if(l==r){t[p].ls=t[p].rs=t[p].s=1; return ;}if(x<=mid) change(p<<1,l,mid,x);else change(p<<1|1,mid+1,r,x);t[p]=merge(t[p<<1],t[p<<1|1],mid-l+1,r-mid);
}
signed main(){cin>>n;for(int i=1;i<=n;i++) scanf("%d",&q[i].a),q[i].id=i;sort(q+1,q+1+n,[](query a,query b){return a.a>b.a;});pos=1;for(int i=1;i<=n;i++){while(t[1].s<i) change(1,1,n,q[pos].id),pos++;printf("%d ",q[pos-1].a);}return 0;
}
Codeforces - Mike and Feet相关推荐
- CodeForces - 548D Mike and Feet(单调栈)
题目链接:点击查看 题目大意:给出一个长度为 n 的数列,现在规定对于任意长度区间为 len 的答案为,所有长度为 len 的区间内的最小值的最大值,题目要求我们输出len为 1 ~ n 时的答案 题 ...
- Codeforces Round #801 (Div. 2)A~C
Codeforces Round #801 (Div. 2)A~C Problem - A - Codeforces Michael and Joe are playing a game. The g ...
- (CodeForces 548B 暴力) Mike and Fun
http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. ...
- Codeforces Round #361 (Div. 2) B. Mike and Shortcuts bfs
B. Mike and Shortcuts 题目连接: http://www.codeforces.com/contest/689/problem/B Description Recently, Mi ...
- Codeforces 798C:Mike and gcd problem
Codeforces 798C:Mike and gcd problem 题目链接:http://codeforces.com/contest/798/problem/C 题目大意:给出一个大小为$n ...
- Codeforces Round #361 (Div. 2) E. Mike and Geometry Problem 【逆元求组合数 离散化】
任意门:http://codeforces.com/contest/689/problem/E E. Mike and Geometry Problem time limit per test 3 s ...
- 【CodeForces - 798A】Mike and palindrome (回文串,水题,字符串问题)
题干: Mike has a string s consisting of only lowercase English letters. He wants to change exactly one ...
- CodeForces - 798B Mike and strings
B. Mike and strings time limit per test2 seconds memory limit per test256 megabytes inputstandard in ...
- 【codeforces 798A】Mike and palindrome
[题目链接]:http://codeforces.com/contest/798/problem/A [题意] 让你严格改变一个字符,使得改变后的字符串为一个回文串; 让你输出可不可能; [题解] 直 ...
- CodeForces 689B Mike and Shortcuts (bfs or 最短路)
Mike and Shortcuts 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/F Description Recently ...
最新文章
- 多账号统一登录(实现方案)
- 将tomcat的session信息通过memcached实现共享
- [转]js escape,encodeURI,encodeURIComponent
- IT人士还是要善待自己
- 更改MOSS所有列表的标题底色
- 抑制恐慌,互联网能够做些什么?
- Oracle面试题及答案整理
- Pygame实战项目:用300行代码写出贪吃蛇小游戏
- 计算机图形与游戏技术,宾夕法尼亚大学计算机图形与游戏技术研究生Offer及录取要求...
- VScode 结局插件prettier和vetur格式化冲突
- Python 字符串/列表/元组/字典之间的相互转换 - Python零基础入门教程
- 什么?你项目还在用Date表示时间?!
- asp.net中日志框架Log4Net的使用
- Mybatis学习随笔
- 响应式个人简历网页源代码
- 如何使用万能地图下载器解决百度地图的偏移问题
- Alfred神器使用手册
- 国际电脑使用执照(ICDL)考试
- iOS--CFMessagePort实现进程间通信
- 桌面文件夹不见了怎么恢复?4招教你找回消失的文件夹
热门文章
- 【资源管理器老是重启 win7资源管理器重启的解决办法】
- 云服务器超级鸟,口袋妖怪超级鸟求口袋妖怪绿宝石超级鸟(小火鸡)技能表要全的 爱问知识人...
- 东京大学情报理工学系研究科招生海报
- c语言数组文曲星猜数游戏编程,第7章 数组-8数组的其他应用——文曲星猜数游戏...
- python笔记1——基础
- hiberfil.sys文件过大
- Repeated DNA Sequences
- hdu 4622 Reincarnation(hash)
- 号外: 我开通了英语专栏
- VSCode自定义网络背景皮肤