結果

問題 No.2240 WAC
コンテスト
ユーザー Muhammad Ashar Usmani
提出日時 2025-11-17 13:44:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,080 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 194,744 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-17 13:44:35
合計ジャッジ時間 4,341 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N, M;
    string S;
    if(!(cin >> N >> M >> S)) return 0;
    long long needWA = N, needAC = M;
    long long w_avail = 0, a_avail = 0;
    for(char ch : S){
        if(ch == 'W'){
            w_avail++;
        } else if(ch == 'A'){
            if(needWA > 0 && w_avail > 0){
                // form WA using one available W and this A
                needWA--;
                w_avail--;
            } else {
                // keep this A for potential AC
                a_avail++;
            }
        } else if(ch == 'C'){
            if(needAC > 0 && a_avail > 0){
                // form AC using one earlier A and this C
                needAC--;
                a_avail--;
            } else {
                cout << "No\n";
                return 0;
            }
        } else {
            // unexpected char, ignore or fail
        }
    }
    if(needWA == 0 && needAC == 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}
0