結果
問題 |
No.24 数当てゲーム
|
ユーザー |
|
提出日時 | 2021-02-17 22:46:36 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,141 bytes |
コンパイル時間 | 3,818 ms |
コンパイル使用メモリ | 81,236 KB |
実行使用メモリ | 41,348 KB |
最終ジャッジ日時 | 2024-09-14 07:40:38 |
合計ジャッジ時間 | 5,846 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 2 |
ソースコード
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>() { { 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()); 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(); } }