結果

問題 No.349 干支の置き物
ユーザー NoiriNoiri
提出日時 2019-02-03 00:17:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 175,712 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-07 10:02:56
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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]++;
    }

    string used;
    for(auto& p: mp){
        if(p.second != 0) used = p.first;
        for(auto& q: mp){
            if(q.first != used && q.second > 0){
                q.second--;
                used = q.first;
            }
        }
    }
    for(int i=0; i<n; i++){
        for(auto& p: mp){
            if(p.second != 0) used = p.first;
            for(auto& q: mp){
                if(q.first != used && q.second > 0){
                    q.second--;
                    used = q.first;
                }
            }
        }
    }

    bool allzero = true;
    for(auto p: mp) if(p.second != 0) allzero = false;
    if(allzero) printf("YES\n");
    else printf("NO\n");
    return 0;
}
0