結果

問題 No.2240 WAC
ユーザー norioc
提出日時 2025-03-25 00:17:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 96,404 KB
最終ジャッジ日時 2025-03-25 00:17:52
合計ジャッジ時間 6,211 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, M = map(int, input().split())
S = input()

s = list(S)
wa = ac = 0
a = deque()
for i in range(len(s)):
    c = S[i]
    if c == 'A':
        a.append(i)
    elif c == 'C':
        if a:
            p = a.popleft()
            ac += 1
            s[p] = '_'

w = 0
for i in range(len(s)):
    c = S[i]
    if c == 'W':
        w += 1
    elif c == 'A':
        if w > 0:
            wa += 1
            w -= 1

if wa >= N and ac >= M:
    print('Yes')
else:
    print('No')
0