結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-29 08:35:31 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 5,000 ms |
| + 507µs | |
| コード長 | 379 bytes |
| 記録 | |
| コンパイル時間 | 58 ms |
| コンパイル使用メモリ | 81,656 KB |
| 実行使用メモリ | 81,152 KB |
| 最終ジャッジ日時 | 2026-07-18 03:36:57 |
| 合計ジャッジ時間 | 2,792 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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