結果

問題 No.349 干支の置き物
ユーザー Noiri
提出日時 2019-02-02 23:50:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 799 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 175,404 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 00:01:50
合計ジャッジ時間 2,883 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(mp[s] == 0) mp[s] = 1;
        else mp[s]++;
    }
    int cnt = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        auto p = (*itr);
        if(p.second != 1){
            cnt = p.second-1;
            itr++;
            for(auto jtr=itr; jtr!=mp.end(); jtr++){
                auto q = (*jtr);
                if(cnt - q.second > 0) cnt -= q.second;
                else{
                    q.second -= cnt;
                    cnt = 0;
                }
            }
        }
        if(cnt != 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}
0