結果
問題 | No.706 多眼生物の調査 |
ユーザー |
![]() |
提出日時 | 2019-11-12 01:28:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 287 ms / 2,000 ms |
コード長 | 654 bytes |
コンパイル時間 | 2,244 ms |
コンパイル使用メモリ | 76,332 KB |
実行使用メモリ | 44,032 KB |
最終ジャッジ日時 | 2024-09-15 12:34:09 |
合計ジャッジ時間 | 4,416 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 |
ソースコード
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); } }