9 solutions

  • 2
    @ 2024-1-28 10:32:13
    #include<bits/stdc++.h>
    using namespace std;
    long n;
    int a[100005];
    long t=1,ma=0;
    int main(){
    	cin>>n;
    	for(int i=0;i<n;i++) cin>>a[i];
    	for(int i=1;i<n;i++){
    		if(a[i]==a[i-1]) t++;
    		ma=max(ma,t);
    		if(a[i]!=a[i-1]) t=1;
    	}
    	cout<<ma<<"\n";
    	return 0;
    }
    
    • 0
      @ 2025-1-30 13:04:25
      #include<bits/stdc++.h>
      using namespace std;
      unsigned short n;
      int li[10005],maxx,ii,len;
      int main(){
         cin>>n;
         for(int i=1;i<=n;i++){
            cin>>li[i];
            if(i==1) len++;
            else if(li[i-1]==li[i]) len++;
            else len=1;
            if(len>maxx) maxx=len;}
         cout<<maxx;
         return 0;
      }
      
      • 0
        @ 2024-10-7 22:16:37
        #include<iostream>
        #include<queue>
        #include<stack>
        #include<cmath>
        #include<algorithm>
        #include<cstring>
        using namespace std;
        int maxn,a[100000];// 全局变量,数组自动初始化为0
        int main()
        {
        	int n,i=1,sum = 1;//i要为1,不然i=0,i--,i=-1(看着极其不顺眼)
        	cin>>n;
        	while(i<=n)
        	{
        		cin>>a[i];
        		if(a[i]==a[i-1]) 
        		{
        			sum++;
        		}
        		else
        		{
        			maxn=max(maxn,sum);//比较,用sort也行
        			sum=1;
        		}
        		i++;
        	}
        	cout<<maxn;
        	return 0;
        }
        
        
        • 0
          @ 2023-10-20 19:45:38
          #include <bits/stdc++.h>
          using namespace std;
          int a[1000005];
          int main(){
          	int n,sum=1,maxn=0;
          	cin>>n;
          	for(int i=1;i<=n;i++){
          		cin>>a[i];
          		if(a[i]==a[i-1]) sum++;
          		else{
          			maxn=max(maxn,sum);
          			sum=1;
          		}
          	}
          	cout<<maxn<<endl;
          	return 0;
          }
          
          • 0
            @ 2023-10-6 10:09:30

            #include using namespace std; int main(int argc, char **argv){ int n,s = 1,mx = 0; cin >> n; int a[n + 5] = {0}; for (int i = 0;i < n;i++){ cin >> a[i]; } for (int i = 1;i < n;i++){ if (a[i] == a[i - 1]){ s++; }else{ s = 1; } mx = max(mx,s); } printf("%d",mx); return 0; }

            • 0
              @ 2023-10-4 14:22:01
              #include <bits/stdc++.h>
              using namespace std;
              int main(int argc, char **argv){
              	int n,s = 1,mx = 0;
              	cin >> n;
              	int a[n + 5] = {0};
              	for (int i = 0;i < n;i++){
              		cin >> a[i];
              	}
              	for (int i = 1;i < n;i++){
              		if (a[i] == a[i - 1]){
              			s++;
              		}else{
              			s = 1;
              		}
              		mx = max(mx,s);
              	}
              	printf("%d",mx);
              	return 0;
              }
              
              • 0
                @ 2023-10-3 15:12:00

                #include<bits/stdc++.h> using namespace std; int main(){ int a; cin>>a; int b[a]; int c[a+1]; int i1,zd=0; for(int i=0;i<a;i++){ cin>>b[i]; } for(int i=0;i<a;i++){ int s=1; i1=i; while(1){ if(b[i1]==b[i1+1]){ s++; }if(b[i1]!=b[i1+1]){ break; } i1++; } c[i]=s; } for(int i=0;i<a;i++){ if(c[i]>zd){ zd=c[i]; } } cout<<zd; }

                • 0
                  @ 2023-10-3 11:39:03

                  #include<bits/stdc++.h> using namespace std; int b[20000000];

                  int main(){ int n,m=0,sum=1,maxbm; cin>>n; const int N=n; int a[N]; for(int i=0;i<N;i++){ cin>>a[i]; } maxbm=b[0]; for(int k=1;k<=N;k++){ if(a[k]==a[k-1]){ sum=sum+1; b[m]=sum; } else{ sum=1; b[m]=sum; }

                  m+=1;
                  
                  }
                  for(int l=0;l<m;l++){
                  	maxbm=max(maxbm,b[l]);
                  }
                  cout<<maxbm;
                  return 0;
                  

                  }

                  • 0
                    @ 2023-9-27 20:25:26
                    #include <set>
                    #include <ios>
                    #include <list>
                    #include <cmath>
                    #include <ctime>
                    #include <queue>
                    #include <deque>
                    #include <stack>
                    #include <vector>
                    #include <bitset>
                    #include <cctype>
                    #include <cerrno>
                    #include <cwchar>
                    #include <cstdio>
                    #include <fenv.h>
                    #include <iosfwd>
                    #include <string>
                    #include <limits>
                    #include <math.h>
                    #include <cstdlib>
                    #include <iomanip>
                    #include <clocale>
                    #include <complex>
                    #include <cstring>
                    #include <cstring>
                    #include <cwctype>
                    #include <istream>
                    #include <ostream>
                    #include <sstream>
                    #include <fstream>
                    #include <utility>
                    #include <stdio.h>
                    #include <iostream>
                    #include <stdint.h>
                    #include <string.h>
                    #include <tgmath.h>
                    #include <complex.h>
                    #include <algorithm>
                    #include <exception>
                    #include <stdbool.h>
                    #include <stdexcept>
                    #include <streambuf>
                    #include <functional>
                    #include <inttypes.h>
                    #include <bits/stdc++.h>
                    using namespace std;
                    int a[1000005];
                    int main(){
                    	int n,sum = 1,maxn = -1;
                    	cin >> n;
                    	for(int i = 1;i <= n;i++){
                    		cin >> a[i];
                    		if(a[i] == a[i-1]){
                    			sum++;
                    		}else{
                    			maxn = max(maxn,sum);
                    			sum = 1;
                    		}
                    	}
                    	cout << maxn;
                    	return 0;
                    }
                    //先思考,别光抄代码!
                    
                    • 1

                    Information

                    ID
                    602
                    Time
                    1000ms
                    Memory
                    256MiB
                    Difficulty
                    4
                    Tags
                    # Submissions
                    126
                    Accepted
                    63
                    Uploaded By