結果

問題 No.24 数当てゲーム
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-12 00:25:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 1,136 bytes
コンパイル時間 3,143 ms
コンパイル使用メモリ 74,468 KB
実行使用メモリ 49,836 KB
最終ジャッジ日時 2023-08-10 23:18:08
合計ジャッジ時間 4,199 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,532 KB
testcase_01 AC 42 ms
49,484 KB
testcase_02 AC 42 ms
49,836 KB
testcase_03 AC 43 ms
49,392 KB
testcase_04 AC 42 ms
49,612 KB
testcase_05 AC 42 ms
49,512 KB
testcase_06 AC 42 ms
49,504 KB
testcase_07 AC 43 ms
49,340 KB
testcase_08 AC 42 ms
49,628 KB
testcase_09 AC 42 ms
49,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No24{
	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int turn = Integer.parseInt(br.readLine());
			kazuate(br, turn);
		}
		catch(IOException e){
			e.getStackTrace();
		}
		catch(NumberFormatException e){
			e.getStackTrace();
		}
	}
	
	public static void kazuate(BufferedReader br, int n) throws IOException, NumberFormatException{
		int[] jiroThought = new int[10];
		int[] taroSuggest = new int[4];
		for(int i=0; i < n; i++){
			String[] str = br.readLine().split(" ");
			for(int j=0; j < 4; j++)
				taroSuggest[j] = Integer.parseInt(str[j]);
			for(int k=0; k < 4; k++){
				if(str[4].equals("YES")) jiroThought[taroSuggest[k]]++;
			    else if (str[4].equals("NO")) jiroThought[taroSuggest[k]]--;
			}
		}
		System.out.println(getIndex(jiroThought));
		}
	
	public static int getIndex(int[] a){
		int ans = 0;
		int max = 0;
		for(int i=0; i < a.length; i++){
			if(max <= a[i]){
				max = a[i];
				ans = i;
			}
		}
		return ans;
	}
}
0