public class Solution {
public static void main(String[] args) throws IOException {
//напишите тут ваш код
ArrayList<Integer> nums = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 10; i++){
nums.add(Integer.parseInt(reader.readLine()));
}
int count = 1;
int max = 0;
for (int i = 0; i < nums.size() - 1; i++){
if (nums.get(i + 1).equals(nums.get(i))) {
count++;
}
else {
if (count >= max){
max = count;
count = 1;
}
}
}
if (count > max) max = count;
System.out.println(max);
}
}
package com.javarush.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
/*
Cамая длинная последовательность
*/
public class Solution {
public static void main(String[] args) throws IOException {
//напишите тут ваш код
ArrayList<Integer> nums = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 10; i++){
nums.add(Integer.parseInt(reader.readLine()));
}
int count = 1;
int max = 0;
for (int i = 0; i < nums.size() - 1; i++){
if (nums.get(i + 1).equals(nums.get(i))) {
count++;
}
else {
if (count >= max){
max = count;
count = 1;
}
}
}
if (count > max) max = count;
System.out.println(max);
}
}