View Code of Problem 82

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Integer get = Integer.valueOf(scanner.nextLine());
        int total_n1 = 0;
        int total_n2 = 0;
        int total_n3 = 0;
        int max = -1;
        int max_index = 0;
        ArrayList<String[]> list = new ArrayList<>();

        for (int i = 0; i < get; i++) {
            String[] split = scanner.nextLine().split(" ");
            int n1 = Integer.parseInt(split[2]);
            int n2 = Integer.parseInt(split[3]);
            int n3 = Integer.parseInt(split[4]);
            if (n1 + n2 + n3 > max) {
                max = n1 + n2 + n3;
                max_index = i;
            }
            total_n2 += n2;
            total_n1 += n1;
            total_n3 += n3;
            list.add(split);
        }
        System.out.println(total_n1 / get + " " + total_n2 / get + " " + total_n3 / get);
        String[] strings = list.get(max_index);
        System.out.println(strings[0] + " " + strings[1] + " " + strings[2] + " " + strings[3] + " " + strings[4]);
    }
}

Double click to view unformatted code.


Back to problem 82