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. VS2012 QT5.2.0 无法解析的外部符号

    背景:在新建QT工程时,可能没有选择一些库,虽然在头文件中引用了,但是程序依然无法识别 现象:一般出现"LNK2019"错误. 解决:以网络为例,在VS2012中加入网络库,分为两 ...

  2. 一些putty的应用设置

    把windows下putty的key转换成linux上使用的rsa key    http://ask.apelearn.com/question/937 putty生成的密钥导入connectbot ...

  3. git命令速记

    对于不常写代码,有的时候又要提交点代码的人来说,git命令记了又忘,忘了又去花精力记住.有没有一种速记方法,来帮助我们记忆这些玩意呢? 纯属抄袭@_@! 除了几个很基本的命令,复杂一点的,我都要去查, ...

  4. CSS布局框架 960GS

    1.960GS 特点 小巧简单,功能单一(仅仅做排版的工作,其他东西靠自己.)(三个文件:reset.css,960.css,font.css) 界面宽960px,适合目前主流1/2以上显示器都满屏宽 ...

  5. c# 计算中文字节数与JAVA不符的解决方法

    c# 中方法 string str = "中华人民共和国"; int strLen = System.Text.Encoding.Default.GetByteCount(str) ...

  6. zabbix selinux audit2allow 问题

    he following example demonstrates using audit2allow to create a policy module: A denial and the asso ...

  7. ubuntu下自动备份mysql数据库

    转载自:Mayi mysql的安装目录为:/var/lib/mysql 下面咱们来一起完成自动备份mysql. 备份目录为:/home/mydb 并且在每天下午18:30分以mysqldata_201 ...

  8. 常用js、jquery 语句(句型)

    1.动态更改设置属性(class  style 都是属性) $("#sendPhoneNum").attr("class", "n_input3&qu ...

  9. nginx的编译,和简单的配置问题

    反向代理常见的lvs.haproxy. 缓存服务常见的.squid.vanish.常见的前端缓存.Apache是多进程的web服务器,Nginx是多线程的web服务器. Nginx的特点,对静态能力强 ...

  10. django中如何将多个app归到一个目录下。

    1.当startapps 生成多个app后,为了便于管理,可新建一个apps目录,把应用全部剪切进apps. 如果是在pycharm中,会提示是否自动更新路径,这里要全部选择取消. QQ群交流:697 ...