結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー r.suzuki
提出日時 2016-01-18 22:06:49
言語 Java
(openjdk 23)
結果
AC  
実行時間 587 ms / 5,000 ms
コード長 1,025 bytes
コンパイル時間 3,773 ms
コンパイル使用メモリ 79,600 KB
実行使用メモリ 47,868 KB
最終ジャッジ日時 2024-06-26 07:48:04
合計ジャッジ時間 12,475 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

enum Level {
	Lv1("1"), Lv2("2"), Lv3("3"), Lv4("4"), Lv5("5"), Lv6("6");
	int count;
	String name;

	Level(String s) {
		this.name = s;
	}

	public String toString() {
		return this.name;
	}

	static void vote(int i) {
		switch (i) {
		case 1:
			Lv1.count++;
			break;
		case 2:
			Lv2.count++;
			break;
		case 3:
			Lv3.count++;
			break;
		case 4:
			Lv4.count++;
			break;
		case 5:
			Lv5.count++;
			break;
		case 6:
			Lv6.count++;
			break;
		}
	}

	static Level judgment() {
		int i = -1;
		Level max = null;
		for (Level l : Level.values()) {
			if (i < l.count) {
				i = l.count;
				max = l;
			} else if (i == l.count) {
				if (Integer.parseInt(max.name) < Integer.parseInt(l.name)) {
					max = l;
				}
			}
		}
		return max;
	}
}

public class No_79 {

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			Level.vote(sc.nextInt());
		}

		System.out.println(Level.judgment());
		sc.close();

	}

}
0