結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー l1267976l1267976
提出日時 2017-03-18 22:37:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 492 ms / 5,000 ms
コード長 1,146 bytes
コンパイル時間 4,285 ms
コンパイル使用メモリ 76,356 KB
実行使用メモリ 62,304 KB
最終ジャッジ日時 2023-09-08 15:06:56
合計ジャッジ時間 12,350 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 206 ms
59,596 KB
testcase_01 AC 465 ms
59,544 KB
testcase_02 AC 131 ms
55,532 KB
testcase_03 AC 129 ms
56,032 KB
testcase_04 AC 121 ms
55,512 KB
testcase_05 AC 469 ms
60,488 KB
testcase_06 AC 122 ms
55,692 KB
testcase_07 AC 122 ms
55,896 KB
testcase_08 AC 121 ms
55,756 KB
testcase_09 AC 122 ms
55,516 KB
testcase_10 AC 122 ms
55,824 KB
testcase_11 AC 122 ms
56,168 KB
testcase_12 AC 121 ms
55,732 KB
testcase_13 AC 122 ms
55,720 KB
testcase_14 AC 396 ms
62,304 KB
testcase_15 AC 329 ms
60,356 KB
testcase_16 AC 428 ms
60,268 KB
testcase_17 AC 297 ms
58,624 KB
testcase_18 AC 440 ms
60,660 KB
testcase_19 AC 382 ms
60,456 KB
testcase_20 AC 491 ms
60,720 KB
testcase_21 AC 193 ms
58,112 KB
testcase_22 AC 333 ms
60,200 KB
testcase_23 AC 460 ms
60,560 KB
testcase_24 AC 492 ms
60,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

}
0