7 solutions

  • 0
    @ 2025-1-16 14:01:46
    #include<iostream>
    using namespace std;
    int main(){
    	int a[100001];
    	int n,temp=1,max=0,t;
    	cin>>n;
    	if(n==1) cout<<1;
    	else
    	{
            for(int i=1;i<=n;i++)
    		{
    		cin>>a[i];
    		}
    		t=a[1];
       		for(int i=2;i<=n;i++)
    		{
    			if(a[i]==t) temp+=1; 
    			else
    			{
    				temp=1;
    				t=a[i];		
    			}
                if(max<temp) max=temp;
    		}
    		cout<<max;	
        }	
    	return 0;
    } 
    

    Information

    ID
    900
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    176
    Accepted
    43
    Uploaded By