public class Solution {
public static void main(String[] args) throws IOException {
ArrayList<Integer> list = reader(new ArrayList<Integer>());
maxSequence(list);
}
public static ArrayList <Integer> reader (ArrayList <Integer> list) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
list.add(Integer.parseInt(reader.readLine()));
if (list.size() == 10) break;
}
return list;
}
public static void maxSequence (ArrayList <Integer> list) {
int count = 1, temp = 1;
for (int i = 0; i < list.size(); i++) {
if (i + 1 == list.size()) break;
if (list.get(i) == list.get(i + 1)) ++count;
else if ((list.get(i) != list.get(i + 1)) && count > temp) {temp = count; count = 1;}
}
if (count != 1 || temp != 1)
System.out.println((count > temp ? count : temp));
else System.out.println(0);
}
}
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> list = reader(new ArrayList<Integer>());
maxSequence(list);
}
public static ArrayList <Integer> reader (ArrayList <Integer> list) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
list.add(Integer.parseInt(reader.readLine()));
if (list.size() == 10) break;
}
return list;
}
public static void maxSequence (ArrayList <Integer> list) {
int count = 1, temp = 1;
for (int i = 0; i < list.size(); i++) {
if (i + 1 == list.size()) break;
if (list.get(i) == list.get(i + 1)) ++count;
else if ((list.get(i) != list.get(i + 1)) && count > temp) {temp = count; count = 1;}
}
if (count != 1 || temp != 1)
System.out.println((count > temp ? count : temp));
else System.out.println(0);
}
}