結果
問題 | No.22 括弧の対応 |
ユーザー | 河野竜也 |
提出日時 | 2021-08-23 22:47:42 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 90 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-08 02:17:23 |
合計ジャッジ時間 | 1,475 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
n,k=map(int,input().split()) s=input() a=s[k-1] ans=0 if a=="(": for i in range(k,n): if ans==0 and s[i]==")": print(i+1) break else: if s[i]=="(": ans+=1 else: ans-=1 if a==")": for i in range(k-2,-1,-1): if ans==0 and s[i]=="(": print(i+1) break else: if s[i]=="(": ans-=1 else: ans+=1