1 条题解

  • 0
    @ 2026-10-25 14:06:59

    思路

    数组已有序,维护当前相等段和最长段。按题面规定的输入输出协议处理;数据、边界和算法核验记录保存在本批教师资料。

    参考程序(C++11)

    #include <bits/stdc++.h>
    using namespace std;
    long long gcdll(long long a,long long b){while(b){long long t=a%b;a=b;b=t;}return a;}
    int main(){ios::sync_with_stdio(false);cin.tie(nullptr);const int p=1116;
    int n,x,last=0,run=0,best=0;cin>>n;for(int i=0;i<n;i++){cin>>x;run=(i&&x==last)?run+1:1;best=max(best,run);last=x;}cout<<best;
    cout<<"\n";return 0;}
    
    • 1

    信息

    ID
    1000
    时间
    1000ms
    内存
    64MiB
    难度
    进阶
    标签
    递交数
    1
    已通过
    1
    上传者