結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー r.suzukir.suzuki
提出日時 2016-01-20 22:54:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 520 ms / 5,000 ms
コード長 1,233 bytes
コンパイル時間 3,421 ms
コンパイル使用メモリ 84,148 KB
実行使用メモリ 61,140 KB
最終ジャッジ日時 2023-09-08 14:43:48
合計ジャッジ時間 11,841 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 233 ms
59,716 KB
testcase_01 AC 508 ms
61,048 KB
testcase_02 AC 127 ms
56,348 KB
testcase_03 AC 127 ms
56,312 KB
testcase_04 AC 127 ms
55,844 KB
testcase_05 AC 520 ms
60,764 KB
testcase_06 AC 129 ms
55,496 KB
testcase_07 AC 127 ms
55,992 KB
testcase_08 AC 122 ms
56,260 KB
testcase_09 AC 122 ms
56,024 KB
testcase_10 AC 124 ms
56,076 KB
testcase_11 AC 124 ms
56,192 KB
testcase_12 AC 123 ms
55,688 KB
testcase_13 AC 128 ms
55,924 KB
testcase_14 AC 426 ms
60,628 KB
testcase_15 AC 317 ms
60,228 KB
testcase_16 AC 462 ms
60,512 KB
testcase_17 AC 307 ms
59,388 KB
testcase_18 AC 459 ms
61,140 KB
testcase_19 AC 417 ms
60,456 KB
testcase_20 AC 500 ms
57,984 KB
testcase_21 AC 211 ms
59,364 KB
testcase_22 AC 353 ms
60,636 KB
testcase_23 AC 494 ms
60,740 KB
testcase_24 AC 493 ms
60,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Counter {
	HashMap<String, Integer> level;

	public Counter() {
		level = new HashMap<String, Integer>();
	}

	public void setLevel(int n) {
		String s;
		for (int i = 1; i <= n; i++) {
			s = "Lv" + String.valueOf(i);
			level.put(s, 0);
		}
	}

	public void voteLevel(int n) {
		String s = "Lv" + String.valueOf(n);
		level.put(s, level.get(s) + 1);
	}

	public String answer() {
		String ans = "";
		int i = -1;
		for (Map.Entry<String, Integer> e : level.entrySet()) {
			if (i < e.getValue()) {
				i = e.getValue();
				ans = e.getKey();
			} else if (i == e.getValue()) {
				int ansi = Integer.parseInt(ans.substring(ans.length() - 1));
				int ei = Integer.parseInt(e.getKey().substring(e.getKey().length() - 1));
				if (ansi < ei) {
					ans = e.getKey();
				}
			}
		}
		return ans.substring(ans.length() - 1);
	}
}

public class No_79_2 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Counter counter = new Counter();
		counter.setLevel(6);

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

		System.out.println(counter.answer());
		sc.close();

	}

}
0