結果

問題 No.24 数当てゲーム
ユーザー yagi2yagi2
提出日時 2017-04-26 12:02:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 1,064 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 83,980 KB
実行使用メモリ 56,280 KB
最終ジャッジ日時 2023-10-11 15:11:44
合計ジャッジ時間 4,382 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,052 KB
testcase_01 AC 122 ms
55,876 KB
testcase_02 AC 122 ms
55,600 KB
testcase_03 AC 124 ms
55,720 KB
testcase_04 AC 123 ms
56,204 KB
testcase_05 AC 124 ms
55,976 KB
testcase_06 AC 124 ms
55,788 KB
testcase_07 AC 125 ms
55,668 KB
testcase_08 AC 123 ms
56,280 KB
testcase_09 AC 123 ms
55,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder.No24;

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> map = new HashMap<>();

        for (int i = 0; i < 10; i++) map.put(i, 1);

        for (int i = 0; i < N; i++) {
            List<Integer> tmp = new ArrayList<>();
            for (int j = 0; j < 4; j++) tmp.add(Integer.parseInt(sc.next()));

            String YN = sc.next();

            if ("YES".equals(YN)) {
                tmp.forEach(integer -> map.put(integer, map.get(integer) + 1));
            }
            if ("NO".equals(YN)) {
                tmp.forEach(integer -> map.put(integer, 0));
            }
        }

        final int[] max = {Integer.MIN_VALUE};
        final int[] ans = {0};
        map.forEach((integer, integer2) -> {
            if (max[0] < integer2) {
                max[0] = integer2;
                ans[0] = integer;
            }
        });
        System.out.println(ans[0]);
    }
}
0