結果

問題 No.2240 WAC
ユーザー roarisroaris
提出日時 2023-03-10 21:34:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,268 KB
実行使用メモリ 76,040 KB
最終ジャッジ日時 2023-10-18 07:15:52
合計ジャッジ時間 3,810 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,152 KB
testcase_01 AC 41 ms
53,152 KB
testcase_02 AC 41 ms
53,152 KB
testcase_03 AC 41 ms
53,152 KB
testcase_04 AC 40 ms
53,152 KB
testcase_05 AC 40 ms
53,152 KB
testcase_06 AC 41 ms
53,152 KB
testcase_07 AC 41 ms
53,152 KB
testcase_08 AC 41 ms
53,152 KB
testcase_09 AC 41 ms
53,152 KB
testcase_10 AC 71 ms
76,040 KB
testcase_11 AC 70 ms
73,992 KB
testcase_12 AC 64 ms
73,964 KB
testcase_13 AC 43 ms
56,516 KB
testcase_14 AC 59 ms
66,312 KB
testcase_15 AC 46 ms
57,808 KB
testcase_16 AC 74 ms
73,016 KB
testcase_17 AC 67 ms
69,996 KB
testcase_18 AC 61 ms
68,524 KB
testcase_19 AC 61 ms
66,648 KB
testcase_20 AC 47 ms
58,028 KB
testcase_21 AC 64 ms
69,428 KB
testcase_22 AC 45 ms
56,944 KB
testcase_23 AC 44 ms
56,516 KB
testcase_24 AC 47 ms
57,768 KB
testcase_25 AC 70 ms
72,412 KB
testcase_26 AC 59 ms
66,668 KB
testcase_27 AC 59 ms
66,448 KB
testcase_28 AC 43 ms
56,144 KB
testcase_29 AC 42 ms
55,520 KB
testcase_30 AC 45 ms
56,952 KB
testcase_31 AC 76 ms
73,816 KB
testcase_32 AC 57 ms
66,404 KB
testcase_33 AC 65 ms
69,824 KB
testcase_34 AC 67 ms
70,220 KB
testcase_35 AC 55 ms
66,092 KB
testcase_36 AC 71 ms
72,560 KB
testcase_37 AC 47 ms
58,352 KB
testcase_38 AC 43 ms
56,164 KB
testcase_39 AC 48 ms
58,832 KB
testcase_40 AC 66 ms
69,660 KB
testcase_41 AC 46 ms
57,576 KB
testcase_42 AC 46 ms
57,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
S = input()[:-1]
q = deque([])
ban = [False]*len(S)

for i in range(len(S)):
    if S[i]=='C':
        if len(q)==0:
            exit(print('No'))
        else:
            ban[q.popleft()] = True
    elif S[i]=='A':
        q.append(i)

W = 0

for i in range(len(S)):
    if ban[i]:
        continue
    
    if S[i]=='W':
        W += 1
    elif S[i]=='A':
        W -= 1
        
        if W<0:
            exit(print('No'))

print('Yes')
0