結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
コンテスト
ユーザー amesyu
提出日時 2025-05-16 21:51:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,668 KB
実行使用メモリ 79,320 KB
最終ジャッジ日時 2025-05-17 00:25:11
合計ジャッジ時間 7,828 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 19 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
s = input()

a = [0]
b = [0]
for i in range(n):
    if s[i] == "(": a.append(a[-1] + 1)
    if s[i] == ")": a.append(a[-1] + -1)
for i in range(n - 1, -1, -1):
    if s[i] == ")": b.append(b[-1] + 1)
    if s[i] == "(": b.append(b[-1] + -1)

x = 0
for i in range(1, n):
    if s[i] == ")":
        if s[i-1] == ")": x += 1
        else: x += 2

if a[-1] == 0 and min(a) == 0 and min(b) == 0 and x <= k:
    print("Yes")
else:
    print("No")
0