結果
問題 | No.22 括弧の対応 |
ユーザー | ytft |
提出日時 | 2022-11-03 17:14:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 231 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,372 KB |
実行使用メモリ | 53,372 KB |
最終ジャッジ日時 | 2024-07-18 01:46:53 |
合計ジャッジ時間 | 1,477 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
import sys input=lambda:sys.stdin.readline().rstrip() N,K=map(int,input().split()) S=input() K-=1 pointer=K count=1 while 1: pointer+=[1,-1][S[K]==')'] count+=[1,-1][S[K]!=S[pointer]] if count==0: print(pointer+1) sys.exit()