結果

問題 No.349 干支の置き物
ユーザー kohaku_kohaku
提出日時 2016-11-13 21:36:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 74,756 KB
実行使用メモリ 41,540 KB
最終ジャッジ日時 2024-11-25 21:59:13
合計ジャッジ時間 6,598 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int h = (N+1)/2;
        String [] E = {"ne","ushi","tora","u","tatsu","mi","uma","hitsuji","saru","tori","inu","i"};
        String [] A = new String [N];
        int [] B = new int [12];
        int max = 0;
        for(int i=0; i<N; i++){
            A[i] = sc.next();
            for(int j=0; j<12; j++){
                if( E[j].equals(A[i]) ){
                    B[j]++;
                    max = Math.max(max, B[j]);
                    break;
                }
            }
            if(max>h){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}
0