kingstertime

Untitled

Sep 25th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class homework3 {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int n = sc.nextInt();
  7. int arr[] = new int[n];
  8. for (int i = 0; i < n; i++) {
  9. arr[i] = sc.nextInt();
  10. }
  11. int a = 0;
  12. int amax = 0;
  13. for (int i = 0; i < n - 1; i++) {
  14. if (arr[i] == arr[i - 1]) {
  15. a += 1;
  16. } else {
  17. if (a > amax) {
  18. amax = a;
  19. }
  20. a = 0;
  21. }
  22. }
  23. System.out.println(amax + 1);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment