結果

問題 No.349 干支の置き物
ユーザー fumi6328
提出日時 2018-09-14 21:29:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 74,932 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 06:39:13
合計ジャッジ時間 1,906 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n,max = 0,cnt = 1;
    cin >> n;
    string a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    sort(a,a+n);

    for(int i = 1; i < n;i++){
        if(a[i-1] == a[i]) cnt++;
        else cnt = 1;
        if(cnt > max) max = cnt;
    }
    
    cout << (max <= n / 2 + n % 2 ? "YES" : "NO") << endl; 

    return 0;
}
0