結果

問題 No.24 数当てゲーム
ユーザー syusyu
提出日時 2020-08-26 21:20:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,349 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 79,096 KB
実行使用メモリ 41,248 KB
最終ジャッジ日時 2024-04-25 03:49:10
合計ジャッジ時間 4,432 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
41,248 KB
testcase_01 AC 128 ms
41,172 KB
testcase_02 AC 131 ms
41,080 KB
testcase_03 AC 126 ms
40,964 KB
testcase_04 AC 133 ms
41,208 KB
testcase_05 AC 135 ms
41,048 KB
testcase_06 AC 131 ms
41,016 KB
testcase_07 AC 130 ms
40,920 KB
testcase_08 AC 131 ms
41,180 KB
testcase_09 AC 133 ms
40,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        
        int n=sc.nextInt();
        Map<Integer,Integer> map=new HashMap<>();
        for(int i=0;i<10;i++){
            map.put(i,0);
        }
        
        for(int i=0;i<n;i++){
            int num_1=sc.nextInt();
            int num_2=sc.nextInt();
            int num_3=sc.nextInt();
            int num_4=sc.nextInt();
            int[] numbers={num_1,num_2,num_3,num_4};
            String result=sc.next();
            
            if(result.equals("NO")){
                for(int number:numbers){
                    int value=map.get(number)-1;
                    map.put(number,value);
                }
            }else{
                for(int number:numbers){
                    int value=map.get(number)+1;
                    map.put(number,value);
                }
            }
        }
        int maxValue=0;
        for(int key:map.keySet()){
            int value=map.get(key);
            if(maxValue<value){
                maxValue=value;
            }
        }
        //System.out.println(maxValue);
        for(int key:map.keySet()){
            int value=map.get(key);
            if(value==maxValue){
                System.out.println(key);
            }
        }
    }
}
0