結果

問題 No.349 干支の置き物
ユーザー matsuyoshi30matsuyoshi30
提出日時 2017-01-25 00:06:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,181 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 74,904 KB
実行使用メモリ 56,232 KB
最終ジャッジ日時 2023-08-24 21:57:30
合計ジャッジ時間 7,324 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,804 KB
testcase_01 AC 120 ms
55,856 KB
testcase_02 AC 124 ms
55,764 KB
testcase_03 AC 124 ms
55,804 KB
testcase_04 AC 128 ms
56,124 KB
testcase_05 AC 129 ms
55,744 KB
testcase_06 AC 127 ms
56,232 KB
testcase_07 AC 125 ms
53,832 KB
testcase_08 AC 125 ms
55,416 KB
testcase_09 AC 125 ms
55,896 KB
testcase_10 AC 124 ms
56,060 KB
testcase_11 AC 126 ms
55,992 KB
testcase_12 AC 128 ms
55,800 KB
testcase_13 AC 129 ms
56,072 KB
testcase_14 AC 126 ms
55,856 KB
testcase_15 AC 129 ms
55,568 KB
testcase_16 AC 128 ms
56,192 KB
testcase_17 AC 123 ms
55,760 KB
testcase_18 AC 122 ms
55,748 KB
testcase_19 WA -
testcase_20 AC 120 ms
56,060 KB
testcase_21 AC 121 ms
55,844 KB
testcase_22 AC 123 ms
55,716 KB
testcase_23 AC 125 ms
55,772 KB
testcase_24 AC 123 ms
55,980 KB
testcase_25 AC 124 ms
55,996 KB
testcase_26 AC 126 ms
56,100 KB
testcase_27 AC 127 ms
56,096 KB
testcase_28 AC 125 ms
55,776 KB
testcase_29 AC 129 ms
55,640 KB
testcase_30 AC 127 ms
55,876 KB
testcase_31 AC 128 ms
55,932 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 = "";

        if(n == 2 && a[0].equals(a[1])) {
            ans = "NO";
        } else {
            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