CF1117A Best Subsegment
CF1117A Best Subsegment
- 乍一看好像很难,仔细想一下发现就是弱智题...
- 任意一段平均数显然不会超过最大的数,若只取最大数即可达到平均数为最大数.
- 于是只用取最长的一段连续的最大数即可.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
inline int read()
{
int x=0;
bool pos=1;
char ch=getchar();
for(;!isdigit(ch);ch=getchar())
if(ch=='-')
pos=0;
for(;isdigit(ch);ch=getchar())
x=x*10+ch-'0';
return pos?x:-x;
}
const int MAXN=1e5+10;
int n,a[MAXN];
int main()
{
int mx=-1;
n=read();
for(int i=1;i<=n;++i)
mx=max(mx,a[i]=read());
int ans=1,len=0;
for(int i=1;i<=n;++i)
if(a[i]==mx)
ans=max(ans,++len);
else
len=0;
printf("%d\n",ans);
return 0 ;
}
CF1117A Best Subsegment的更多相关文章
- [CC-SEINC]Sereja and Subsegment Increasings
[CC-SEINC]Sereja and Subsegment Increasings 题目大意: 有长度为\(n(n\le10^5)\)的序列\(A\)和\(B\). 在一次操作中,可以选择一个区间 ...
- [CF997E] Good SubSegment
Description Transmission Gate 给你一个长度为n的排列P,定义一段子区间是好的,当且仅当这个子区间内的值构成了连续的一段.例如对于排列\(\{1,3,2\}\),\([1, ...
- CF724D. Dense Subsequence[贪心 字典序!]
D. Dense Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces Round #369 (Div. 2)---C - Coloring Trees (很妙的DP题)
题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has a ...
- Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组
E. George and Cards George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees DP
C. Coloring Trees ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the pa ...
- DZY Loves Sequences
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- ACM: Copying Data 线段树-成段更新-解题报告
Copying Data Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description W ...
- C. Coloring Trees DP
传送门:http://codeforces.com/problemset/problem/711/C 题目: C. Coloring Trees time limit per test 2 secon ...
随机推荐
- MySQL 存储过程参数用法 in, out, inout
MySQL 存储过程参数有三种类型:in.out.inout.它们各有什么作用和特点呢? 一.MySQL 存储过程参数(in) MySQL 存储过程 “in” 参数:跟 C 语言的函数参数的值传递类似 ...
- angular2中的路由转场动效
1.为什么有的人路由转动效离场动效不生效? 自己研究发现是加动效的位置放错了 如下: <---! animate-state.component.html --> <div sty ...
- JSP 异常处理
JSP 异常处理 当编写JSP程序的时候,程序员可能会遗漏一些BUG,这些BUG可能会出现在程序的任何地方.JSP代码中通常有以下几类异常: 检查型异常:检查型异常就是一个典型的用户错误或者一个程序员 ...
- Android 版本升级涉及到的数据库数据迁移问题
最近做老版本向新版本升级,新版本增加了几张表,有的表经过了增加字段.那么如何把老的数据迁移到新的版本里呢? 我写了一段伪代码,是关于我们项目里的 用户登录信息 Users表, 历史表histor ...
- 第九天 1-8 RHEL7软件包管理
在RHEL7中,主要有 RPM 和 YUM 两种包管理 1.RPM包管理--使用rpm命令对rpm软件包进行管理rpm命令格式:[有很多,自己可以man一下,这里只列举一下常用的]rpm -ivh [ ...
- torch 深度学习 (2)
torch 深度学习 (2) torch ConvNet 前面我们完成了数据的下载和预处理,接下来就该搭建网络模型了,CNN网络的东西可以参考博主 zouxy09的系列文章Deep Learning ...
- python环境配置
有个chatserver.py文件写的服务器代码,mac下终端执行python chatserver.py 总是报上面的错,求解 ImportError: No module named twist ...
- Python中面向对象的一些关于类变量与实例变量的理解
1. 要写出有意义的面向对象的代码,最核心的:类.对象.三大特性:继承.封装.多态 类变量与实例变量: class Student(): # 类变量 name = '张' age = 0 def __ ...
- 为什么是link-visited-hover-active
前言 通常我们在设置链接的一些伪类(link,visited,hover,active)样式时,要让不同的状态显示正确的样式,我们需要按一定的顺序设置这些伪类的样式.这里我就按CSS2规范中推荐的顺序 ...
- SQL SERVER 正则替换
use pubdbgo IF OBJECT_ID(N'dbo.RegexReplace') IS NOT NULL DROP FUNCTION dbo.RegexReplace GO --开始创建正则 ...