結果
| 問題 | No.3143 Colorless Green Parentheses Sleep Furiously |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-31 10:52:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 536 bytes |
| 記録 | |
| コンパイル時間 | 3,440 ms |
| コンパイル使用メモリ | 82,344 KB |
| 実行使用メモリ | 84,340 KB |
| 最終ジャッジ日時 | 2025-12-31 10:53:03 |
| 合計ジャッジ時間 | 10,270 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 35 |
ソースコード
N,K=map(int,input().split())
S=input()
sm=0
depth=0
mx_depth=0
ans=[]
for i,s in enumerate(S):
if s=="(":
if i>0 and S[i-1]==")":ans.append("+")
ans.append(s)
depth+=1
mx_depth+=1
else:
if depth==mx_depth:ans.append("1+1"+s);sm+=2
else:ans.append("+1"+s);sm+=1
depth-=1
if depth==0:mx_depth=0
if sm>K:exit(print("No"))
if sm==K:
print("Yes")
print("".join(ans))
else:
while sm<K:
ans.append("+1");sm+=1
print("Yes")
print("".join(ans))