結果

問題 No.24 数当てゲーム
ユーザー YOSHIYOSHI
提出日時 2021-02-17 19:37:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 6,498 ms
コンパイル使用メモリ 75,884 KB
実行使用メモリ 56,244 KB
最終ジャッジ日時 2023-10-12 05:52:55
合計ジャッジ時間 8,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 126 ms
55,836 KB
testcase_02 AC 125 ms
55,644 KB
testcase_03 AC 126 ms
55,636 KB
testcase_04 WA -
testcase_05 AC 127 ms
55,668 KB
testcase_06 AC 127 ms
55,592 KB
testcase_07 AC 126 ms
55,644 KB
testcase_08 WA -
testcase_09 AC 126 ms
55,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No00000024_Main2 {

	public static void main(String[] args) {

		Map<String, Integer> cntMap = new HashMap<String, Integer>();
		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], 1);
					}
				}
			} else {
				for(int k = 0; k < 4; k++) {
					cntMap.remove(arr[k]);
				}
			}
		}

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

		System.out.println(result);

		scan.close();

	}

}
0