Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. using namespace std;
  4. int total[1000005],ma=-10,n,cnt[1000005];
  5.  
  6. void find(){
  7. int prev=total[1],ind=0;
  8. for(int i=1;i<=n;i++){
  9. if(total[i]==0) continue;
  10. if(prev==total[i]) ind++;
  11. else if(prev!=total[i]){
  12. ma=max(ma,ind);
  13. ind=1;
  14. }
  15. prev=total[i];
  16. }
  17. if(ind!=0) ma=max(ma,ind);
  18. }
  19.  
  20. int main()
  21. {
  22. scanf("%d",&n);
  23. for(int i=1;i<=n;i++){
  24. scanf("%d",&total[i]);
  25. cnt[total[i]]++;
  26. }
  27. for(int i=1;i<=n;i++){
  28. if(cnt[i]!=0){
  29. for(int j=1;j<=n;j++) if(total[j]==i) total[j]=0;
  30. find();
  31. for(int k=1;k<=n;k++) if(total[k]==0) total[k]=i;
  32. }
  33. }
  34. if(ma==-10) printf("0");
  35. else printf("%d",ma);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement