結果

問題 No.24 数当てゲーム
コンテスト
ユーザー AoiroFukurou
提出日時 2016-05-23 13:36:19
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 909 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,483 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 42,800 KB
最終ジャッジ日時 2026-04-23 17:15:41
合計ジャッジ時間 3,971 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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