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的更多相关文章

  1. [CC-SEINC]Sereja and Subsegment Increasings

    [CC-SEINC]Sereja and Subsegment Increasings 题目大意: 有长度为\(n(n\le10^5)\)的序列\(A\)和\(B\). 在一次操作中,可以选择一个区间 ...

  2. [CF997E] Good SubSegment

    Description Transmission Gate 给你一个长度为n的排列P,定义一段子区间是好的,当且仅当这个子区间内的值构成了连续的一段.例如对于排列\(\{1,3,2\}\),\([1, ...

  3. CF724D. Dense Subsequence[贪心 字典序!]

    D. Dense Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. DZY Loves Sequences

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  8. ACM: Copying Data 线段树-成段更新-解题报告

    Copying Data Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description W ...

  9. C. Coloring Trees DP

    传送门:http://codeforces.com/problemset/problem/711/C 题目: C. Coloring Trees time limit per test 2 secon ...

随机推荐

  1. Glibc-2.3.4编译

    $tar xf Glibc2.3.4.tar.bz2 $mkdir build_glibc $cd build_glibc ../glibc-2.3.4/configure --prefix=/too ...

  2. AtCoder Grand Round 012B Splatter Painting

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  3. Java循环跳转语句之 break

    生活中,我们经常会因为某些原因中断既定的任务安排.如在参加 10000 米长跑时,才跑了 500 米就由于体力不支,需要退出比赛.在 Java 中,我们可以使用 break 语句退出指定的循环,直接执 ...

  4. PHP 循环中临时对象不销毁,会保存到一下循环,这是什么坑。。

    在C++中,根本存在这种问题,一个对象或结构体在循环中声明赋值了,再一次循环就自动清空.但是在PHP中这个$monthData在下一次循环却不会重新赋值,而是保留了上一次赋值的值,这样的下一次save ...

  5. 前端项目,引入PingFang SC字体

    在仿苹果官网"垃圾桶"时, 设计出的UI使用PingFang SC 字体,在网上查了很久,特记录.如果你有更好的方法,欢迎评论留言~ 实现原理,使用@font-face将字体下载在 ...

  6. vim 正则 捕获

    在正规表达式中使用 \( 和 \) 符号括起正规表达式,即可在后面使用\1 \2等变量来访问捕获的内容. 将捕获内容前后交换,如下: :s/\(\haha\)\(hehe\)/\\/

  7. javascript中的__proto__ 和prototype

    不错的一张图

  8. Python实现CSV数据的读取--两种方法实现

    方法一: 方法二:

  9. php上传多文件max_file_uploads限制问题

    在PHP程序中,常常会遇到这种问题,上传附件时明明成功上传了很多附件,如图片等,但实际上只存在20个附件,或者直接报错无法上传. 在DEDECMS5.7编辑图集的时候,发现只要超过20张图片保存就会出 ...

  10. 初次安装git配置用户名和邮箱及密钥

    在Windows上安装Git: 在Windows上使用Git,可以从Git官网直接下载安装程序,(网速慢的同学请移步国内镜像),然后按默认选项安装即可. 安装完成后 键盘敲上:windows+r你会看 ...