結果

問題 No.24 数当てゲーム
ユーザー face4face4
提出日時 2018-04-16 21:31:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 1,037 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 70,748 KB
実行使用メモリ 49,296 KB
最終ジャッジ日時 2023-09-09 10:57:19
合計ジャッジ時間 3,011 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,256 KB
testcase_01 AC 43 ms
47,472 KB
testcase_02 AC 43 ms
49,228 KB
testcase_03 AC 43 ms
48,908 KB
testcase_04 AC 43 ms
49,144 KB
testcase_05 AC 43 ms
49,020 KB
testcase_06 AC 43 ms
49,048 KB
testcase_07 AC 42 ms
49,048 KB
testcase_08 AC 42 ms
47,188 KB
testcase_09 AC 43 ms
49,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[10];
        while (n-- > 0) {
            String[] input = br.readLine().split(" ");
            if (input[4].equals("YES")) {
                for (int i = 0; i < 4; i++) {
                    arr[Integer.parseInt(input[i])]++;
                }
            } else if (input[4].equals("NO")) {
                for (int i = 0; i < 4; i++) {
                    arr[Integer.parseInt(input[i])]--;
                }
            }
        }

        int maxIndex = 0;
        int maxValue = arr[0];
        for (int i = 1; i < 10; i++) {
            if (maxValue < arr[i]) {
                maxIndex = i;
                maxValue = arr[i];
            }
        }

        System.out.println(maxIndex);
    }
}
0