結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-29 08:35:31 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 5,000 ms |
| コード長 | 379 bytes |
| コンパイル時間 | 103 ms |
| コンパイル使用メモリ | 6,912 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2024-07-20 07:09:40 |
| 合計ジャッジ時間 | 1,295 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#coding: utf-8
##yuki_22
nk=map(int,raw_input().split())
s=raw_input()
n=nk[0]
k=nk[1]
k=k-1
count=0
if s[k]=='(':
for i in xrange(k,n):
if s[i]=='(':
count+=1
elif s[i]==')':
count-=1
if count==0:
rt=i
break
elif s[k]==')':
for i in xrange(k,-1,-1):
if s[i]==')':
count+=1
elif s[i]=='(':
count-=1
if count==0:
rt=i
break
print rt+1