結果
問題 |
No.2240 WAC
|
ユーザー |
![]() |
提出日時 | 2023-03-11 00:01:52 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 777 bytes |
コンパイル時間 | 732 ms |
コンパイル使用メモリ | 79,476 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-18 05:47:07 |
合計ジャッジ時間 | 2,119 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 43 |
ソースコード
#include <iostream> #include <string> using namespace std; bool check(string s, char a, char b) { int na = 0; for (auto c : s) { if (c == a) ++na; else --na; if (na < 0) return false; } return true; } int main() { int N, M; string S; cin >> N >> M >> S; string wa, ac; int naac = 0; for (auto c : S) { if (c == 'W') { wa += c; } else if (c == 'C') { ac += c; } else { if (naac < M) { ac += c; ++naac; } else { wa += c; } } } if (check(ac, 'A', 'C') and check(wa, 'W', 'A')) { puts("Yes"); } else { puts("No"); } }