結果

問題 No.582 キャンディー・ボックス3
ユーザー @abcde@abcde
提出日時 2019-05-29 00:29:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,005 bytes
コンパイル時間 1,659 ms
コンパイル使用メモリ 167,524 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 18:35:21
合計ジャッジ時間 2,967 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){

    // 1. 入力情報取得.
    int N;
    cin >> N;
    LL C[N], candy = 0;
    for(int i = 0; i < N; i++) cin >> C[i], candy += C[i];
    
    // 2. キャンディーを取っていく.
    // 2-1. C[i] >= 3 の 箱 があれば, 手番を操作できる B の勝ち.
    for(int i = 0; i < N; i++){
        if(C[i] >= 3){
            cout << "B" << endl;
            return 0;
        }
    }
    
    // 2-2. C[i] == 2 の 箱 が 2個以上ある場合は, 手番を操作できる B の勝ち.
    int two = 0;
    for(int i = 0; i < N; i++) if(C[i] == 2) two++;
    if(two >= 2){
        cout << "B" << endl;
        return 0;
    }

    // 2-3. C[i] == 2 の 箱 が 1個以下の場合は, 箱の合計数で, A, B の勝敗が決まる.
    if(two <= 1){
        if(candy % 2 == 0) cout << "B" << endl;
        else               cout << "A" << endl;
    }

    // 3. 出力 ~ 後処理.
    return 0;
    
}
0