• + 0 comments

    All cases are OK, but the "congrulations" message does not appear.

    public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        List<List<Integer>> arr = new ArrayList<>();
    
        for (int i = 0; i < 6; i++) {
            String[] arrRowTempItems = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
    
            List<Integer> arrRowItems = new ArrayList<>();
    
            for (int j = 0; j < 6; j++) {
                int arrItem = Integer.parseInt(arrRowTempItems[j]);
                arrRowItems.add(arrItem);
            }
    
            arr.add(arrRowItems);
        }
        int maxSum = Integer.MIN_VALUE;
        for (int i = 0; i < 5; i++) {    
    
            for (int j = 0; j < 5; j++){ 
    
                if(i+2 < arr.size() && j+2 < arr.get(i).size()){
    
                    int sum = arr.get(i).get(j) + arr.get(i).get(j+1) 
                            + arr.get(i).get(j+2) + arr.get(i+1).get(j+1)
                            + arr.get(i+2).get(j) + arr.get(i+2).get(j+1) 
                            + arr.get(i+2).get(j+2);
    
                                maxSum = Math.max(maxSum, sum);
                }
            }
        }
        System.out.print(maxSum);
    
        bufferedReader.close();
    }
    

    }