結果

問題 No.582 キャンディー・ボックス3
ユーザー snrnsidy
提出日時 2025-09-08 17:09:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 208,424 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-08 17:09:54
合計ジャッジ時間 3,311 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 5 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> v;
    int n,x;
    long long int sum = 0;

    cin >> n;

    for(int i=0;i<n;i++)
    {
        cin >> x;
        if (x > 0) v.push_back(x);
        sum += x;
    }
    sort(v.begin(), v.end());

    if (sum == 0)
    {
        cout << "B" << '\n';
    }
    if (v.back() == 1) 
    {
        if (sum % 2 == 0) 
        {
            cout << "B" << '\n';
        }
        else
        {
            cout << "A" << '\n';
        }
    }

    map<int, int> cnt;
    for(auto x : v) cnt[x] += 1;

    if (cnt[2] == 1 and v.size() == (cnt[1] + cnt[2]) and cnt[1] % 2 == 1) 
    {
        cout << "A" << '\n';
    }
    else
    {
        cout << "B" << '\n';
    }
    return 0;   
}
0