結果
問題 | No.79 過小評価ダメ・ゼッタイ |
ユーザー |
|
提出日時 | 2017-03-18 22:37:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 597 ms / 5,000 ms |
コード長 | 1,146 bytes |
コンパイル時間 | 3,922 ms |
コンパイル使用メモリ | 88,040 KB |
実行使用メモリ | 47,984 KB |
最終ジャッジ日時 | 2024-06-26 08:10:53 |
合計ジャッジ時間 | 13,105 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; public class No79 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < n; i++) { int li = sc.nextInt(); if (map.containsKey(li)) { map.put(li, map.get(li) + 1); } else { map.put(li, 1); } } int maxCnt = 0; for (Map.Entry<Integer, Integer> e : map.entrySet()) { if (e.getValue() > maxCnt) { maxCnt = e.getValue(); } } List<Integer> resultList = new ArrayList<>(); for (Map.Entry<Integer, Integer> e : map.entrySet()) { if (e.getValue() == maxCnt) { resultList.add(e.getKey()); } } Collections.sort(resultList); System.out.println(resultList.get(resultList.size() - 1)); sc.close(); } }