結果

問題 No.24 数当てゲーム
ユーザー ryosuke0825ryosuke0825
提出日時 2018-04-11 06:47:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 1,138 bytes
コンパイル時間 3,581 ms
コンパイル使用メモリ 74,884 KB
実行使用メモリ 56,292 KB
最終ジャッジ日時 2023-09-09 04:04:05
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,204 KB
testcase_01 AC 121 ms
56,064 KB
testcase_02 AC 123 ms
56,232 KB
testcase_03 AC 122 ms
55,780 KB
testcase_04 AC 121 ms
55,676 KB
testcase_05 AC 122 ms
56,072 KB
testcase_06 AC 124 ms
55,832 KB
testcase_07 AC 123 ms
56,292 KB
testcase_08 AC 121 ms
55,924 KB
testcase_09 AC 119 ms
55,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class No24 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> noList = new ArrayList<Integer>();
		ArrayList<Integer> yesList = new ArrayList<Integer>();

		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			int D = sc.nextInt();
			String R = sc.next();

			if (R.equals("YES")) {
				yesList.add(A);
				yesList.add(B);
				yesList.add(C);
				yesList.add(D);
			} else {
				noList.add(A);
				noList.add(B);
				noList.add(C);
				noList.add(D);
			}
		}

		if (yesList.size() == 0) {
			for (int i = 0; i < 10; i++) {
				if (!noList.contains(i)) {
					System.out.println(i);
				}
			}
		} else {

			int mostNo = 0;
			int mostCount = 0;
			for (int i : yesList) {
				if (noList.contains(i)) {
					continue;
				}
				int count = 0;
				for (int j : yesList) {
					if (i == j) {
						count++;
					}
				}
				if (mostCount < count) {
					mostNo = i;
					mostCount = count;
				}
			}
			System.out.println(mostNo);
		}

	}

}
0