結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-20 18:42:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 497 ms / 5,000 ms
コード長 683 bytes
コンパイル時間 3,083 ms
コンパイル使用メモリ 74,564 KB
実行使用メモリ 62,696 KB
最終ジャッジ日時 2023-09-08 15:17:30
合計ジャッジ時間 10,607 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 203 ms
59,348 KB
testcase_01 AC 446 ms
60,696 KB
testcase_02 AC 121 ms
55,956 KB
testcase_03 AC 121 ms
56,472 KB
testcase_04 AC 121 ms
56,448 KB
testcase_05 AC 497 ms
60,384 KB
testcase_06 AC 123 ms
55,500 KB
testcase_07 AC 121 ms
56,092 KB
testcase_08 AC 123 ms
55,868 KB
testcase_09 AC 126 ms
55,680 KB
testcase_10 AC 120 ms
55,932 KB
testcase_11 AC 121 ms
55,788 KB
testcase_12 AC 124 ms
55,740 KB
testcase_13 AC 122 ms
56,116 KB
testcase_14 AC 385 ms
60,032 KB
testcase_15 AC 302 ms
60,272 KB
testcase_16 AC 422 ms
60,348 KB
testcase_17 AC 294 ms
60,448 KB
testcase_18 AC 423 ms
60,684 KB
testcase_19 AC 384 ms
60,272 KB
testcase_20 AC 462 ms
60,384 KB
testcase_21 AC 199 ms
58,816 KB
testcase_22 AC 335 ms
60,340 KB
testcase_23 AC 458 ms
59,980 KB
testcase_24 AC 462 ms
62,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
 	}
}

0