結果

問題 No.349 干支の置き物
ユーザー matsuyoshi30matsuyoshi30
提出日時 2017-01-24 23:59:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 72,612 KB
実行使用メモリ 56,448 KB
最終ジャッジ日時 2023-08-24 21:57:04
合計ジャッジ時間 7,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,144 KB
testcase_01 AC 123 ms
55,744 KB
testcase_02 AC 121 ms
56,028 KB
testcase_03 AC 121 ms
55,972 KB
testcase_04 AC 128 ms
55,872 KB
testcase_05 AC 125 ms
56,040 KB
testcase_06 AC 124 ms
55,488 KB
testcase_07 AC 122 ms
55,992 KB
testcase_08 AC 127 ms
55,884 KB
testcase_09 AC 129 ms
56,044 KB
testcase_10 AC 122 ms
55,580 KB
testcase_11 AC 127 ms
55,992 KB
testcase_12 AC 126 ms
55,988 KB
testcase_13 AC 125 ms
55,768 KB
testcase_14 AC 124 ms
54,272 KB
testcase_15 AC 125 ms
56,060 KB
testcase_16 AC 124 ms
56,052 KB
testcase_17 AC 122 ms
55,764 KB
testcase_18 AC 121 ms
55,684 KB
testcase_19 WA -
testcase_20 AC 124 ms
55,860 KB
testcase_21 WA -
testcase_22 AC 121 ms
55,808 KB
testcase_23 AC 120 ms
56,448 KB
testcase_24 AC 122 ms
55,784 KB
testcase_25 AC 122 ms
55,844 KB
testcase_26 AC 125 ms
55,780 KB
testcase_27 AC 126 ms
56,024 KB
testcase_28 AC 124 ms
56,132 KB
testcase_29 AC 125 ms
55,776 KB
testcase_30 AC 128 ms
56,164 KB
testcase_31 AC 129 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] a = new String[n];

        for(int i=0; i<n; i++) {
            a[i] = in.next();
        }

        /*
          N個の干支の置物がある
          12種類の干支のうち、どれかひとつでもN/2+1個以上あれば
          隣に置かざるをえない
         */

        String[] eto = {"ne", "ushi", "tora", "u", "tatsu", "mi", "uma", "hitsuji", "saru", "tori", "inu", "i"};

        String ans = "YES";

        for(int i=0; i<12; i++) {
            int count = 0;
            for(int j=0; j<n; j++) {
                if(a[j].equals(eto[i])) {
                    count++;
                }
            }
            if(count > n/2 + 1) {
                ans = "NO";
                break;
            }
        }

        System.out.println(ans);

        in.close();
    }
}
0