結果
| 問題 | No.24 数当てゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-08 17:14:19 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 5,000 ms |
| コード長 | 1,449 bytes |
| コンパイル時間 | 2,371 ms |
| コンパイル使用メモリ | 81,624 KB |
| 実行使用メモリ | 54,440 KB |
| 最終ジャッジ日時 | 2024-06-23 19:12:30 |
| 合計ジャッジ時間 | 4,366 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < 10; i++) {
map.put(i, 0);
}
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int n = Integer.parseInt(str);
for (int i = 0; i < n; i++) {
String[] strs = sc.nextLine().split(" ");
int a[] = new int[4];
for (int j = 0; j < a.length; j++) {
a[j] = Integer.parseInt(strs[j]);
}
String r = strs[4];
if (r.equals("NO")) {
for (int j = 0; j < a.length; j++) {
if (map.containsKey(a[j])) {
map.remove(a[j]);
}
}
} else {
for (int j = 0; j < a.length; j++) {
if (map.containsKey(a[j])) {
map.put(a[j], map.get(a[j]) + 1);
}
}
}
}
int maxCnt = -1;
int maxNo = -1;
for (Map.Entry<Integer, Integer> e : map.entrySet()) {
if (e.getValue() > maxCnt) {
maxCnt = e.getValue();
maxNo = e.getKey();
}
}
System.out.println(maxNo);
sc.close();
}
}