結果

問題 No.2240 WAC
ユーザー 👑 rin204
提出日時 2024-04-28 14:46:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 95,000 KB
最終ジャッジ日時 2024-11-17 07:29:53
合計ジャッジ時間 5,470 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
WA = []
AC = []
c = 0
S = input()

for s in S:
    if s == "W":
        WA.append(1)
    elif s == "C":
        AC.append(-1)
    elif c < m:
        c += 1
        AC.append(1)
    else:
        WA.append(-1)


def ok(S):
    tot = 0
    for s in S:
        tot += s
        if tot < 0:
            return False
    return tot == 0


if ok(WA) and ok(AC):
    print("Yes")
else:
    print("No")
0