結果
問題 |
No.79 過小評価ダメ・ゼッタイ
|
ユーザー |
![]() |
提出日時 | 2017-10-20 18:42:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 595 ms / 5,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 2,350 ms |
コンパイル使用メモリ | 76,528 KB |
実行使用メモリ | 48,752 KB |
最終ジャッジ日時 | 2024-06-26 08:20:44 |
合計ジャッジ時間 | 11,413 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n]; for(int i = 0 ; i < n ; i++) { l[i] = sc.nextInt(); } Map<Integer, Integer> map = new HashMap<>(); for(int i = 0 ; i < n ; i++) { map.put(l[i], 0); } for(int i = 0 ; i < n ; i++) { map.put(l[i], map.get(l[i]) + 1); } int max = -1001001001; int ans = 0; for(int key : map.keySet()) { if(max < map.get(key) || max == map.get(key) && ans < key) { ans = key; max = map.get(key); } } System.out.println(ans); } }