cf982d Shark
#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;
}
cf982d Shark的更多相关文章
- 机器学习库shark安装
经过两天的折腾,一个对c++和机器学习库的安装都一知半解的人终于在反复安装中,成功的将shark库安装好了,小小纪念一下,多亏了卡门的热心帮忙. shark的安装主要分为以下几个部分: (1)下载 s ...
- 【CodeForces 621A】Wet Shark and Odd and Even
题 Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wan ...
- 【CodeForces 621C】Wet Shark and Flowers
题 There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such tha ...
- Apache Spark Shark的简介
Shark是构建在Spark和Hive基础之上的数据仓库. 目前,Shark已经完成学术使命,终止开发,但其架构和原理仍具有借鉴意义. 它提供了能够查询Hive中所存储数据的一套SQL接口,兼容现有的 ...
- shark错误:Query returned non-zero code: -101
环境:shark(0.11分支编译)+spark 0.8+hive 0.11(编译)+hadoop 2.00 cdh4.4 用sharkserver的方式执行一段时间后,通过kit-b8连接到ki ...
- Spark、Shark集群安装部署及遇到的问题解决
1.部署环境 OS:Red Hat Enterprise Linux Server release 6.4 (Santiago) Hadoop:Hadoop 2.4.1 Hive:0.11.0 JDK ...
- Wet Shark and Flowers(思维)
C. Wet Shark and Flowers time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- B. Wet Shark and Bishops(思维)
B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- cf-A. Wet Shark and Odd and Even(水)
A. Wet Shark and Odd and Even time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
随机推荐
- blog 题解目录
洛谷: 1.P2430 严酷的训练 2.CF784E Twisted Circuit 3.P1886 滑动窗口 4.P1090 合并果子 5.P1119 灾后重建 6.P1690 贪婪的Copy 7. ...
- CF1136D Nastya Is Buying Lunch
思路: 1. 最终答案不超过能与Nastya“直接交换”的人数. 2. 对于排在j前面的i,如果i和i-j之间(包括j)的每个人都能“直接交换”,j才能前进一步. 实现: #include <b ...
- C#中Dictionary泛型集合7种常见的用法
要使用Dictionary集合,需要导入C#泛型命名空间 System.Collections.Generic(程序集:mscorlib) Dictionary的描述1.从一组键(Key)到一组值( ...
- 9.26<立方网>技术笔试题
该公司题目感觉不难,算法设计有三道大题. 1.设有m和n两个整数,求它们的最大公约数和最小公倍数. 2.猴子分桃问题,每次分桃多一个,共有五个猴子,问最少有多少个桃子. 3.关于java的题目,有A, ...
- jquery-weui picker组件实现只选择年月
var date = new Date() var month = date.getMonth()+1 //获取当前月份 $('#selectTime').picker({ toolbarTempla ...
- 在IIS 7.5上安装WebDAV(http文件下载上传)
WebDAV 简介 WebDAV (Web-based Distributed Authoring and Versioning) 一种基于 HTTP 1.1协议的通信协议.它扩展了HTTP 1.1, ...
- Coursera 算法二 week 4 Boggle
这次的作业主要用到了单词查找树和深度优先搜索. 1.在深度优先搜索中,在当前层的递归调用前,将marked数组标记为true.当递归调用返回到当前层时,应将marked数组标记为false.这样既可以 ...
- IOS segue(跳转页面处理)
● Storyboard上每一根用来界面跳转的线,都是一个UIStoryboardSegue对象(简称Segue) Segue的属性 ● 每一个Segue对象,都有3个属性 ➢ 唯一标识 @prope ...
- 传入指定字段名称就可以排序的EF写法
private static IQueryable<T> SetQueryableOrder<T>(this IQueryable<T> query, string ...
- POJ-1936 All in All---字符串水题
题目链接: https://vjudge.net/problem/POJ-1936 题目大意: 给两个字符串,判断是s1是不是s2的子序列 思路: 水 #include<iostream> ...