結果

問題 No.706 多眼生物の調査
ユーザー htensaihtensai
提出日時 2019-11-12 01:28:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 72,280 KB
実行使用メモリ 60,476 KB
最終ジャッジ日時 2023-10-13 16:35:46
合計ジャッジ時間 4,432 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
56,400 KB
testcase_01 AC 115 ms
55,932 KB
testcase_02 AC 121 ms
56,040 KB
testcase_03 AC 144 ms
56,672 KB
testcase_04 AC 155 ms
56,252 KB
testcase_05 AC 209 ms
57,816 KB
testcase_06 AC 250 ms
60,476 KB
testcase_07 AC 115 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
		    int x = sc.next().length();
		    if (map.containsKey(x)) {
		        map.put(x, map.get(x) + 1);
		    } else {
		        map.put(x, 1);
		    }
		}
		int max = 0;
		int maxIdx = 0;
		for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
		    if (entry.getValue() >= max) {
		        max = entry.getValue();
		        maxIdx = entry.getKey();
		    }
		}
		System.out.println(maxIdx - 2);
	}
}
0