A.找到最大值x,再找出最长的连续的x。

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<iostream>
 4 #include<algorithm>
 5 #define rep(i,l,r) for (int i=(l); i<=(r); i++)
 6 typedef long long ll;
 7 using namespace std;
 8 
 9 const int N=100010;
10 int n,tot,mx,ans,a[N];
11 
12 int main(){
13     scanf("%d",&n);
14     rep(i,1,n) scanf("%d",&a[i]),mx=max(mx,a[i]);
15     rep(i,1,n) if (a[i]==mx) tot++; else ans=max(ans,tot),tot=0;
16     printf("%d\n",max(ans,tot));
17     return 0;
18 }
A

相关文章:

  • 2021-09-04
  • 2021-06-26
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2021-12-23
  • 2021-05-17
猜你喜欢
  • 2021-10-15
  • 2021-05-12
  • 2020-07-14
  • 2021-06-18
  • 2021-05-28
  • 2021-07-21
  • 2021-09-09
相关资源
相似解决方案