結果

問題 No.24 数当てゲーム
ユーザー YOSHIYOSHI
提出日時 2021-02-17 19:18:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,289 bytes
コンパイル時間 4,066 ms
コンパイル使用メモリ 81,300 KB
実行使用メモリ 55,836 KB
最終ジャッジ日時 2023-10-12 05:40:35
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,456 KB
testcase_01 AC 127 ms
55,704 KB
testcase_02 AC 127 ms
55,640 KB
testcase_03 AC 128 ms
55,836 KB
testcase_04 AC 129 ms
55,632 KB
testcase_05 AC 131 ms
55,672 KB
testcase_06 AC 132 ms
55,672 KB
testcase_07 AC 132 ms
55,704 KB
testcase_08 AC 135 ms
55,392 KB
testcase_09 AC 129 ms
55,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class No00000024_Main {

	public static void main(String[] args) {

		Map<String, Integer> cntMap = new HashMap<String, Integer>() {
			{
				put("0", 0);
				put("1", 0);
				put("2", 0);
				put("3", 0);
				put("4", 0);
				put("5", 0);
				put("6", 0);
				put("7", 0);
				put("8", 0);
				put("9", 0);
			}
		};
		Scanner scan = new Scanner(System.in);

		int n = Integer.parseInt(scan.nextLine());
		for(int i = 0; i < n; i++) {
			String[] arr = scan.nextLine().split(" ");
			if("YES".equals(arr[4])) {
				for(int j = 0; j < 4; j++) {
					if(cntMap.containsKey(arr[j])) {
						cntMap.put(arr[j], cntMap.get(arr[j]) + 1);
					} else {
						cntMap.put(arr[j], 0);
					}
				}
			} else {
				for(int k = 0; k < 4; k++) {
					cntMap.remove(arr[k]);
				}
			}
		}

		String result = "";
		if(cntMap.keySet().size() == 1) {
			for(Entry<String, Integer> entry : cntMap.entrySet()) {
				result = entry.getKey();
			}
		} else {
			int temp = 0;
			for(Entry<String, Integer> entry : cntMap.entrySet()) {
				if(temp < entry.getValue()) {
					result = entry.getKey();
					temp = entry.getValue();
				}
			}
		}

		System.out.println(result);

		scan.close();

	}

}
0