結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー 回転
提出日時 2025-05-16 22:02:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 231,408 KB
最終ジャッジ日時 2025-05-17 00:27:47
合計ジャッジ時間 10,953 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41 WA * 2 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = list(map(int,input().split()))
S = input()

stack = []
for i in S:
    if(i == "("):
        stack.append("(")
    else:
        if(stack):
            stack.pop()
        else:
            print("No")
            exit()
if(stack):
    print("No")
    exit()

ans = []
for i in S:
    if(i == "("):
        if(ans and ans[-1] == ")"):ans.append("+")
        ans.append("(")
        ans.append("1")
        ans.append("+")
    else:
        if(ans[-1] == "+"):ans.append("1")
        ans.append(")")

anss = "".join(ans)
if(eval(anss) <= K):
    print("Yes")
    print(anss + "+1"*(K-eval(anss)))
else:
    print("No")
0