結果
問題 |
No.24 数当てゲーム
|
ユーザー |
|
提出日時 | 2021-02-17 19:37:47 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 954 bytes |
コンパイル時間 | 5,635 ms |
コンパイル使用メモリ | 85,176 KB |
実行使用メモリ | 55,772 KB |
最終ジャッジ日時 | 2024-09-14 05:17:27 |
合計ジャッジ時間 | 5,970 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 WA * 3 |
ソースコード
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(); } }