ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1585. Penguins

Java ez
Posted by Aleksandr 21 Dec 2025 03:18
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String a = "Emperor Penguin";
        String b = "Macaroni Penguin";
        String c = "Little Penguin";
        int countA = 0;
        int countB = 0;
        int countC = 0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> list = new ArrayList<>(n);
        sc.nextLine();
        for (int i = 0; i < n; i++){
            list.add(sc.nextLine());
        }
        for (String item: list){
            if (item.equals(a)){
                countA++;
            } else if (item.equals(b)) {
                countB++;
            } else if (item.equals(c)) {
                countC++;
            }
        }
        int max = Math.max(Math.max(countA,countB),countC);
        if (max == countA){
            System.out.println(a);
        } else if (max == countB) {
            System.out.println(b);
        } else if (max == countC) {
            System.out.println(c);
        }
    }
}