結果

問題 No.24 数当てゲーム
ユーザー AoiroFukurouAoiroFukurou
提出日時 2016-05-23 13:35:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 909 bytes
コンパイル時間 6,377 ms
コンパイル使用メモリ 77,276 KB
実行使用メモリ 54,388 KB
最終ジャッジ日時 2024-04-16 09:05:36
合計ジャッジ時間 6,267 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
54,012 KB
testcase_01 AC 137 ms
53,932 KB
testcase_02 AC 139 ms
53,844 KB
testcase_03 AC 137 ms
54,164 KB
testcase_04 AC 136 ms
54,084 KB
testcase_05 AC 138 ms
54,024 KB
testcase_06 AC 137 ms
54,164 KB
testcase_07 AC 135 ms
53,832 KB
testcase_08 AC 138 ms
54,300 KB
testcase_09 AC 137 ms
54,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class No24 {// 数当てゲーム
	public static void main(String[] args) {
		int[] num = new int[10];
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			int[] h = new int[4];// Hint
			String s = null;
			h[0] = sc.nextInt();
			h[1] = sc.nextInt();
			h[2] = sc.nextInt();
			h[3] = sc.nextInt();
			s = sc.nextLine();
			if (s.equals(" YES")) {
				yes(num, h);
			} else {
				no(num, h);
			}
		}
		sc.close();
		int ans = 0;
		for (int i = 1; i < 10; i++) {
			if (num[ans] < num[i]) {
				ans = i;
			}
		}
		System.out.println(ans);
	}

	public static int[] yes(int[] num, int[] h) {// YESの場合
		for (int i = 0; i < 4; i++) {
			num[h[i]]++;
		}
		return num;
	}

	public static int[] no(int[] num, int[] h) {// NOの場合
		for (int i = 0; i < 4; i++) {
			num[h[i]]--;
		}
		return num;
	}
}
0