結果
問題 | No.349 干支の置き物 |
ユーザー |
|
提出日時 | 2016-05-04 12:59:35 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 972 bytes |
コンパイル時間 | 2,387 ms |
コンパイル使用メモリ | 79,128 KB |
実行使用メモリ | 41,420 KB |
最終ジャッジ日時 | 2024-11-17 07:31:34 |
合計ジャッジ時間 | 7,790 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
import java.util.HashMap; import java.util.Map; import java.util.Scanner; enum Eto { ne, ushi, tora, u, tatsu, mi, uma, hitsuji, saru, tori, inu, i; } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] input = new String[51]; if (args.length == 0) { int i = 0; while (sc.hasNext()) { input[i] = sc.nextLine(); i++; } } else { input = args; } System.out.println(solve(input)); sc.close(); } public static String solve(String[] in) { boolean ans = true; Map<Eto, Integer> d = new HashMap<>(); for (Eto e : Eto.values()) { d.put(e, 0); } int total = 0; for (int i = 1; i < in.length; i++) { if(in[i] == null || in[i].isEmpty()){ continue; } Eto e = Eto.valueOf(in[i]); d.put(e, d.get(e) + 1); total++; } for (Eto e : Eto.values()) { if (total - d.get(e) < d.get(e) - 1) { ans = false; } } return ans ? "YES" : "NO"; } }