結果
| 問題 | 
                            No.349 干支の置き物
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Tsukasa_Type
                         | 
                    
| 提出日時 | 2018-03-01 00:03:39 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 153 ms / 2,000 ms | 
| コード長 | 560 bytes | 
| コンパイル時間 | 2,667 ms | 
| コンパイル使用メモリ | 76,672 KB | 
| 実行使用メモリ | 41,500 KB | 
| 最終ジャッジ日時 | 2024-12-23 02:22:08 | 
| 合計ジャッジ時間 | 8,207 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 | 
ソースコード
import java.util.*;
import static java.lang.System.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		Map<String,Integer> map = new LinkedHashMap<>();
		String s;
		for (int i=0; i<n; i++) {
			s = sc.next();
			map.put(s,map.getOrDefault(s,0));
			map.put(s,map.get(s)+1);
		}
		int max = -1;
		for (Map.Entry<String,Integer> entry : map.entrySet()) {
			max = Math.max(max,entry.getValue());
		}
		if (max <= (n+1)/2) {out.println("YES");}
		else {out.println("NO");}
	}
}
            
            
            
        
            
Tsukasa_Type