結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,796 KB
testcase_01 AC 122 ms
56,384 KB
testcase_02 AC 121 ms
55,612 KB
testcase_03 AC 122 ms
55,844 KB
testcase_04 AC 127 ms
55,996 KB
testcase_05 AC 128 ms
56,156 KB
testcase_06 AC 125 ms
56,180 KB
testcase_07 AC 124 ms
56,176 KB
testcase_08 AC 125 ms
56,260 KB
testcase_09 AC 125 ms
55,448 KB
testcase_10 AC 124 ms
56,276 KB
testcase_11 AC 126 ms
55,464 KB
testcase_12 AC 127 ms
56,104 KB
testcase_13 AC 126 ms
56,188 KB
testcase_14 AC 124 ms
56,092 KB
testcase_15 AC 127 ms
56,088 KB
testcase_16 AC 126 ms
55,588 KB
testcase_17 AC 121 ms
56,088 KB
testcase_18 AC 123 ms
57,740 KB
testcase_19 WA -
testcase_20 AC 120 ms
55,608 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 122 ms
55,572 KB
testcase_24 WA -
testcase_25 AC 118 ms
55,924 KB
testcase_26 AC 126 ms
56,096 KB
testcase_27 AC 128 ms
56,172 KB
testcase_28 AC 128 ms
55,856 KB
testcase_29 WA -
testcase_30 AC 131 ms
55,604 KB
testcase_31 AC 126 ms
56,368 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(n % 2 == 0) {
                if(count > n/2 + 1) {
                    ans = "NO";
                    break;
                }
            } else {
                if(count >= n/2 + 1) {
                    ans = "NO";
                    break;
                }
            }
        }

        System.out.println(ans);

        in.close();
    }
}
0