結果

問題 No.24 数当てゲーム
ユーザー YOSHIYOSHI
提出日時 2021-02-17 22:56:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 1,249 bytes
コンパイル時間 3,326 ms
コンパイル使用メモリ 79,416 KB
実行使用メモリ 56,196 KB
最終ジャッジ日時 2023-10-12 08:46:00
合計ジャッジ時間 5,191 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,824 KB
testcase_01 AC 115 ms
55,552 KB
testcase_02 AC 116 ms
56,196 KB
testcase_03 AC 117 ms
55,804 KB
testcase_04 AC 118 ms
55,972 KB
testcase_05 AC 118 ms
55,588 KB
testcase_06 AC 116 ms
55,868 KB
testcase_07 AC 118 ms
56,116 KB
testcase_08 AC 117 ms
55,860 KB
testcase_09 AC 117 ms
55,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No00000024_Main2 {

	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());
		Set<String> noSet = new HashSet<String>();
		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(!noSet.contains(arr[j]) && cntMap.containsKey(arr[j])) {
						cntMap.put(arr[j], cntMap.get(arr[j]) + 1);
					}
				}
			} else {
				for(int k = 0; k < 4; k++) {
					noSet.add(arr[k]);
				}
			}
		}

		String result = "";
		int temp = -1;
		for(Entry<String, Integer> entry : cntMap.entrySet()) {
			if(!noSet.contains(entry.getKey()) && temp < entry.getValue()) {
				result = entry.getKey();
				temp = entry.getValue();
			}
		}

		System.out.println(result);

		scan.close();

	}

}
0