結果

問題 No.349 干支の置き物
ユーザー NoiriNoiri
提出日時 2019-02-02 23:50:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 799 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 175,368 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 08:43:45
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
5,376 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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