题目链接

题意:让你去掉一个数,使得剩下的数的record最多,当1≤j&lt;i的aj&lt;ai1 \leq j&lt; i的a_j&lt;a_i1≤j<i的aj​<ai​时aia_iai​为recordrecordrecord数。

解法:遍历数组每个数,记录最大和次大值,用cntcntcnt数组记录,移除某个数后造成的recordrecordrecord数变化量。然后输出最优的即可。

#include<bits/stdc++.h>

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back using namespace std; LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
int n,a[100003],pos[100003],cnt[100003];
int main(){
ios::sync_with_stdio(false);
cin>>n;
int ans=1,m1=-32323,m2=-32323;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]>m1){
m2=m1;
m1=a[i];
cnt[a[i]]=-1;
}else if(a[i]>m2)m2=a[i],cnt[m1]++;
}
int ret=-32323;
for(int i=1;i<=n;i++){
if(cnt[i]>ret){
ret=cnt[i];
ans=i;
}
}
cout<<ans<<endl;
return 0;
}

Codeforces Round #450 (Div. 2) C. Remove Extra One的更多相关文章

  1. Codeforces Round #450 (Div. 2) C. Remove Extra One【*模拟链表/一个数比前面所有数大就是个record。删掉一个数,让record的个数尽量多。】

    C. Remove Extra One time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #450 (Div. 2) A. Find Extra One【模拟/判断是否能去掉一个点保证剩下的点在Y轴同侧】

    A. Find Extra One time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  3. Codeforces Round #450 (Div. 2)

    Codeforces Round #450 (Div. 2) http://codeforces.com/contest/900 A #include<bits/stdc++.h> usi ...

  4. Codeforces Round #450 (Div. 2) ABCD

    这次还是能看的0 0,没出现一题掉分情况. QAQ前两次掉分还被hack了0 0,两行清泪. A. Find Extra One   You have n distinct points on a p ...

  5. 【Codeforces Round #450 (Div. 2) C】Remove Extra One

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举删除第i个数字. 想想删掉这个数字后会有什么影响? 首先,如果a[i]如果是a[1..i]中最大的数字 那么record会减少1 ...

  6. 【Codeforces Round #450 (Div. 2) A】Find Extra One

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟. 看看Y左边或右边的点个数是否<=1 [代码] #include <bits/stdc++.h> using ...

  7. Codeforces Round #605 (Div. 3) D. Remove One Element(DP)

    链接: https://codeforces.com/contest/1272/problem/D 题意: You are given an array a consisting of n integ ...

  8. Codeforces Round #450 (Div. 2) D.Unusual Sequences (数学)

    题目链接: http://codeforces.com/contest/900/problem/D 题意: 给你 \(x\) 和 \(y\),让你求同时满足这两个条件的序列的个数: \(a_1, a_ ...

  9. Codeforces Round #481 (Div. 3) A. Remove Duplicates

    题目地址:http://codeforces.com/contest/978/problem/A 题解:给一串长度为n的数组,然后删去相同的数字(从右往左). 方法:题目n和数组ai给的范围都很小,所 ...

随机推荐

  1. python描述器

    描述器定义 python中,一个类实现了__get__,__set__,__delete__,三个方法中的任何一个方法就是描述器,仅实现__get__方法就是非数据描述器,同时实现__get__,__ ...

  2. win32-api: 让 static 控件中的水平横行,垂直居中。

    CreateWindowEx(....., SS_CENTER | SS_CENTERIMAGE); SS_CENTER  能让文字水平居中. SS_CENTERIMAGE 能让文字垂直居中. htt ...

  3. 大型游戏案例UI开发总结_1

    Canvas(画布)中选择Render Mode----Screen Space Camera,为了在摄像机和UI画布之间放置3D物体. Camera中的Projection选择Orthographi ...

  4. ttribute "xmlns" was already specified for element "web-app".

    今天导入了,一个javaweb项目,当自己对项目进行重命名的时候时候,但是web.xml直接爆出来一个"ttribute "xmlns" was already spec ...

  5. Office-kms

    Office 2016 VOL Office Office 2016 Pro Plus 32 位专业增强版 文件名 SW_DVD5_Office_Professional_Plus_2016_W32_ ...

  6. Kafka技术内幕 读书笔记之(一) Kafka入门

    在0.10版本之前, Kafka仅仅作为一个消息系统,主要用来解决应用解耦. 异步消息 . 流量削峰等问题. 在0.10版本之后, Kafka提供了连接器与流处理的能力,它也从分布式的消息系统逐渐成为 ...

  7. 【英文文档】Solidifier for Windows Installation Guide

    Page 1Solidifier for Windows  Installation Guide Page 2McAfee, Inc.McAfee® Solidifier for Windows In ...

  8. 加密PDF文件的打印问题

    工作中遇到网上下载的PDF文件加密,并且不能打印 解决方法: 1.解密: 去网站下载解密软件,1M左右:http://www.onlinedown.net/soft/19939.htm 直接解压,运行 ...

  9. Maccms8.x 命令执行漏洞分析

    下载链接https://share.weiyun.com/23802397ed25681ad45c112bf34cc6db 首先打开Index.php $m = be('get','m'); m参数获 ...

  10. nginx 前端POST请求405问题解决与排查过程

    问题描述 在请求时,f12提示POST请求报错405 环境描述 nginx转发至后端nginx,后端nginx转发至后端golang api接口 解决步骤 根据网上方法排查,发现80%以上无非就是以下 ...