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. PHP Fatal error: Call to undefined function imagecreatetruecolor()

    是因为没有安装gd apt-get install libgd2-xpm-dev* apt-get install php5-gd

  2. 网络流learning

    上次学习网络流还是大一的下学期,之后就被从图论分出来交给队友了 然而吉林一战,队友在深圳读研而不能来,于是需要自己学习一下,争取在比赛前看完网络流建模汇总和一些总结,升华一下. 同时记录一下自己做过的 ...

  3. 关于Google play无法下载应用

    查看网络连接是否正常 查看账号信息 以上两种都没有问题,那可能是缓存的问题,去应用里面清楚缓存以后,重启手机. 如果还是不行,就在应用程序中 清除全部数据,重启手机,这样就可以了. ps:不管你行不行 ...

  4. mysql 的行转列 PIVOT 的使用

    语句:SELECT DataDate , PropertyText , DataValue FROM RPT_ReportProperty p WITH ( NOLOCK ) JOIN RPT_Rep ...

  5. 淘海外分发Job 多线程demo

    using System;using System.Collections.Generic;using System.Configuration;using System.Diagnostics;us ...

  6. Struts2 入门实例

    一.最简登录 Demo:login.jsp——web.xml——struts.xml——LoginAction.java——struts.xml——index.jsp 1.下载 Struts2 框架: ...

  7. 【Python】模块学习之(__call__)实现准确计算函数运行时间

    背景 博主在写自动化的过程中,有遇到有的用例运行缓慢的问题,想起在上一家公司的的“自动化工厂”有一个指标:两小时内运行完所有的用例才算合格.所以想计算每一个用例的运行时间. 思路 因为使用的POM模型 ...

  8. 虚拟机中的Linux安装VMware Tools的方法

    先检查虚拟机是否能上网 一:安装VMware Tools的之前必装的工具套件方法如下: Centos安装VMware Tools: [root@piaoyun-vm vmware-tools-dist ...

  9. 关于BFS和dijkstra(2019.04.20)

    我的BFS板子 struct node{/*略*/};//表示一个状态 std::map<node,bool>vis;//判断每个状态是否已访问过 std::queue<node&g ...

  10. 十八 Python分布式爬虫打造搜索引擎Scrapy精讲—Scrapy启动文件的配置—xpath表达式

    我们自定义一个main.py来作为启动文件 main.py #!/usr/bin/env python # -*- coding:utf8 -*- from scrapy.cmdline import ...