結果

問題 No.24 数当てゲーム
ユーザー jimanojimano
提出日時 2016-07-18 17:24:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 1,055 bytes
コンパイル時間 3,267 ms
コンパイル使用メモリ 78,476 KB
実行使用メモリ 50,476 KB
最終ジャッジ日時 2024-04-23 16:30:10
合計ジャッジ時間 4,457 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
50,476 KB
testcase_01 AC 56 ms
49,984 KB
testcase_02 AC 55 ms
50,292 KB
testcase_03 AC 57 ms
50,108 KB
testcase_04 AC 56 ms
50,128 KB
testcase_05 AC 55 ms
50,220 KB
testcase_06 AC 55 ms
50,184 KB
testcase_07 AC 56 ms
50,280 KB
testcase_08 AC 56 ms
50,432 KB
testcase_09 AC 56 ms
50,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No0024 {
	public static void main(String[] args) {
		try (BufferedReader br = 
				new BufferedReader(new InputStreamReader(System.in))) {
	        int cntTurn = Integer.parseInt(br.readLine());
	        String[] str;
	        int[] num = new int[10];

		    for(int i =0; i < cntTurn ; i++){
		    	str = br.readLine().trim().split(" ");
		    	if(str[str.length - 1].endsWith("NO")){
		    		for(int j = 0; j < str.length - 1; j++){
		    			num[Integer.parseInt(str[j])] = -1;//リセット
		    		}
		    	}
		    	else if(str[str.length - 1].endsWith("YES")){
		    		for(int j = 0; j < str.length - 1; j++){
		    			num[Integer.parseInt(str[j])] += 1;
		    		}
		    	}
		    }
		    int max = 0;
		    for(int n:num){
		    	max = Math.max(max, n);
		    }
		    for(int i = 0; i < num.length ; i++){
		    	if(num[i] == max){
		    		System.out.println(i);
		    	}
		    }
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
}
0