結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー yagi2yagi2
提出日時 2017-04-25 14:37:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 397 ms / 5,000 ms
コード長 940 bytes
コンパイル時間 2,900 ms
コンパイル使用メモリ 89,376 KB
実行使用メモリ 61,312 KB
最終ジャッジ日時 2023-09-08 15:08:33
合計ジャッジ時間 9,463 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
58,884 KB
testcase_01 AC 392 ms
60,864 KB
testcase_02 AC 117 ms
55,696 KB
testcase_03 AC 118 ms
56,260 KB
testcase_04 AC 120 ms
55,936 KB
testcase_05 AC 389 ms
61,164 KB
testcase_06 AC 118 ms
56,008 KB
testcase_07 AC 118 ms
56,480 KB
testcase_08 AC 121 ms
55,740 KB
testcase_09 AC 119 ms
55,844 KB
testcase_10 AC 119 ms
55,828 KB
testcase_11 AC 121 ms
56,064 KB
testcase_12 AC 119 ms
55,928 KB
testcase_13 AC 117 ms
56,160 KB
testcase_14 AC 334 ms
60,136 KB
testcase_15 AC 249 ms
60,440 KB
testcase_16 AC 362 ms
60,744 KB
testcase_17 AC 244 ms
60,200 KB
testcase_18 AC 355 ms
60,216 KB
testcase_19 AC 317 ms
61,024 KB
testcase_20 AC 397 ms
61,312 KB
testcase_21 AC 174 ms
56,816 KB
testcase_22 AC 279 ms
60,516 KB
testcase_23 AC 380 ms
61,036 KB
testcase_24 AC 385 ms
61,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());

        Map<Integer, Integer> L = new HashMap<>();
        for (int i = 0 ; i < N; i++) {
            int l = Integer.parseInt(sc.next());

            if (!L.containsKey(l)) L.put(l, 0);
            L.put(l, L.get(l)+1);
        }

        List<Map.Entry<Integer, Integer>> entryList = new ArrayList<>(L.entrySet());
        entryList.sort((o1, o2) -> {
            if (o1.getValue() > o2.getValue()) return -1;
            if (o1.getValue() < o2.getValue()) return 1;

            if (Objects.equals(o1.getValue(), o2.getValue())) {
                if (o1.getKey() > o2.getKey()) return -1;
                if (o1.getKey() < o2.getKey()) return 1;
            }
            return 0;
        });

        System.out.println(entryList.get(0).getKey());
    }
}
0