ref

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> par;
int n;
par a[100005];
set<par> se;
map<int,int> mp;
int main(){
cin>>n;
for(int i=1; i<=n; i++){
scanf("%d", &a[i].first);
a[i].second = i;
}
sort(a+1, a+1+n);
se.insert(par(1, n));
mp[n] = 1;
int maxn=0, ans=-1;
for(int i=n; i; i--){
if(mp.size()==1 && mp.begin()->second>=maxn){
maxn = mp.begin()->second;
ans = a[i].first + 1;
}
set<par>::iterator it=se.upper_bound(par(a[i].second, 0x3f3f3f3f));
it--;
if(it->first<=a[i].second-1){
par x(it->first, a[i].second-1);
se.insert(x);
mp[x.second-x.first+1]++;
}
if(a[i].second+1<=it->second){
par x(a[i].second+1, it->second);
se.insert(x);
mp[x.second-x.first+1]++;
}
int len=it->second-it->first+1;
se.erase(it);
mp[len]--;
if(!mp[len]) mp.erase(len);
}
cout<<ans<<endl;
return 0;
}

最新文章

  1. CSS中position小解
  2. 【51nod】区间求和
  3. NopCommerce 框架系列(二)
  4. Hexo部署到GitHub出现spawn ENOENT的解决办法
  5. EPANET头文件解读系列8——FUNCS.H
  6. dom 拖拽回放
  7. hdu 3544 Alice&#39;s Game
  8. jQuery对象和Dom对象的区分以及之间转换
  9. Android Touch系统简介(二):实例详解onInterceptTouchEvent与onTouchEvent的调用过程
  10. .NET/ASP.NETMVC Model元数据、HtmlHelper、自定义模板、模板的装饰者模式(一)
  11. windows下使用命令查看端口占用情况
  12. C#读取和写入文件
  13. .Net多线程编程—Parallel LINQ、线程池
  14. 2017多校第10场 HDU 6180 Schedule 贪心,multiset
  15. javascript创建数组的所有方式【Array老师】
  16. python之__new__()
  17. Nginx详解二十五:Nginx架构篇之Nginx常见的问题
  18. 【emWin】例程三十一:窗口对象——Multipage
  19. Lucene 学习-安装 Kibana 视图界面
  20. linux系统下php通过php_oci8扩展连接oracle数据库 Nginx

热门文章

  1. ArcGIS for Android 10.1.1API 中文标注导致程序异常崩溃问题
  2. 定制Banner
  3. javascript设计模式之装饰者模式
  4. PHP中MySQL数据库连接,数据读写,修改方法
  5. POJ-1274 The Perfect Stall---二分图模板
  6. Android(java)学习笔记88:BaseAdapter适配器重写之getView()
  7. vuejs数据和事件
  8. iOS 常用正则表达式
  9. systemd 中的requires, wants, before, after
  10. MRCA|Wright–Fisher population genetic model|SNP rate