Codeforces Round #450 (Div. 2) C. Remove Extra One
题目链接
题意:让你去掉一个数,使得剩下的数的record最多,当1≤j<i的aj<ai1 \leq j< i的a_j<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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #450 (Div. 2)
Codeforces Round #450 (Div. 2) http://codeforces.com/contest/900 A #include<bits/stdc++.h> usi ...
- Codeforces Round #450 (Div. 2) ABCD
这次还是能看的0 0,没出现一题掉分情况. QAQ前两次掉分还被hack了0 0,两行清泪. A. Find Extra One You have n distinct points on a p ...
- 【Codeforces Round #450 (Div. 2) C】Remove Extra One
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举删除第i个数字. 想想删掉这个数字后会有什么影响? 首先,如果a[i]如果是a[1..i]中最大的数字 那么record会减少1 ...
- 【Codeforces Round #450 (Div. 2) A】Find Extra One
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟. 看看Y左边或右边的点个数是否<=1 [代码] #include <bits/stdc++.h> using ...
- 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 ...
- Codeforces Round #450 (Div. 2) D.Unusual Sequences (数学)
题目链接: http://codeforces.com/contest/900/problem/D 题意: 给你 \(x\) 和 \(y\),让你求同时满足这两个条件的序列的个数: \(a_1, a_ ...
- Codeforces Round #481 (Div. 3) A. Remove Duplicates
题目地址:http://codeforces.com/contest/978/problem/A 题解:给一串长度为n的数组,然后删去相同的数字(从右往左). 方法:题目n和数组ai给的范围都很小,所 ...
随机推荐
- 后缀数组的第X种求法
后缀自动机构造后缀数组. 因为有个SB题洛谷5115,它逼迫我学习后缀数组...(边分树合并是啥?). 一些定义:sa[i]表示字典序排第i的后缀是从哪里开始的.Rank[i]表示后缀i的排名.hei ...
- [luogu1486][郁闷的出纳员]
题目链接 思路 这个题其实就是对于treap中的删除操作进行一些修改.自己yy了一种做法.就是在删除的时候,如果要删除的数比这棵子树的根大,那么就把根变成根的右孩子,这样就相当于删除了整棵左子树和根节 ...
- 第二十五篇-Android 应用资源
这里介绍android的一些资源文件. 以一个登录界面为例. layout.xml <?xml version="1.0" encoding="utf-8" ...
- 【译】5. Java反射——方法
原文地址:http://tutorials.jenkov.com/java-reflection/methods.html ====================================== ...
- python学习笔记—Day1
1. python使用<变量名>=<表达式>的方式对变量进行赋值 a=1; python中数分为整数和浮点数 字符串的定义一定要用引号,单引号和双引号是等价的 三引号用来输入包 ...
- 详解Vue 开发模式下跨域问题
vue项目中,前端与后台进行数据请求或者提交的时候,如果后台没有设置跨域,前端本地调试代码的时候就会报“No 'Access-Control-Allow-Origin' header is prese ...
- python自动化开发-[第十七天]-django的ORM与其他
今日概要: 1.name别名 2.模版的深度查询 3.模版语言之filter 4.自定义过滤器,filter和simpletag的区别 5.orm进阶 扫盲:url的组成 URL:协议+域名+端口+路 ...
- python机器学习-sklearn挖掘乳腺癌细胞(五)
python机器学习-sklearn挖掘乳腺癌细胞( 博主亲自录制) 网易云观看地址 https://study.163.com/course/introduction.htm?courseId=10 ...
- urllib 学习二
编码解码: python2 用法: urllib.urlencode() 编码 urlparse.parse_qs() 解码 python3 用法: urllib.parse.urlencode() ...
- /etc/fstab 文件挂载配置文件
(1)/etc/fstab 每行定义一个要挂载的文件系统 mount -a 自动挂载/etc/fstab文件没有挂载的设备,不管已挂载过的设备 如果想刷新修改过已挂载的设备,mount -o remo ...