結果

問題 No.2240 WAC
コンテスト
ユーザー rin204
提出日時 2024-04-28 14:46:03
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 429 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 311 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 103,936 KB
最終ジャッジ日時 2026-05-12 07:15:54
合計ジャッジ時間 3,348 ms
ジャッジサーバーID
(参考情報)
tmp-judge_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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