結果

問題 No.3143 Colorless Green Parentheses Sleep Furiously
ユーザー moon17
提出日時 2025-05-16 22:06:08
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 349 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,080 KB
実行使用メモリ 168,876 KB
最終ジャッジ日時 2025-05-17 00:28:29
合計ジャッジ時間 9,365 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 1 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k=map(int,input().split())
s=input()
t=s
q=[]
f=0
for i in range(n):
  c=s[i]
  q+=c,
  if q[-2:]==[*'()']:
    q.pop()
    q.pop()
  if not q and i+1<n:
    f=1
if q:
  exit(print('No'))
t=t.replace('()','(1)')
t=t.replace('(','(1+')
t=t.replace(')(',')+(')
if f<1:
  t+='+1'
s=eval(t)
if s>k:
  exit(print('No'))
print('Yes')
print(t+'+1'*(k-s))
0