fork(1) download
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. long long n,i,max1=0,length=1,index=0,x,l2;
  6. cin>>n;
  7. for(i=0;i<n;i++)
  8. {
  9. cin>>x;
  10. if(x>max1)
  11. {
  12. max1=x;
  13.  
  14. l2=1;
  15. index=i;
  16.  
  17. }
  18. else if(x==max1&&i==index+1)
  19. {
  20.  
  21. ++l2;
  22. index=i;
  23.  
  24. }
  25. if(i!=index&&x==max1)
  26. {
  27. index=i;
  28. l2=1;
  29. }
  30.  
  31. if(l2>length)
  32. {
  33. length=l2;
  34. }
  35.  
  36. }
  37. cout<<length<<endl;
  38. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1