結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-29 08:35:31 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
AC
不安定
|
| 実行時間 | 71 ms / 5,000 ms |
| + 533µs | |
| コード長 | 379 bytes |
| 記録 | |
| コンパイル時間 | 84 ms |
| コンパイル使用メモリ | 62,592 KB |
| 実行使用メモリ | 62,720 KB |
| 最終ジャッジ日時 | 2026-11-10 18:55:24 |
| 合計ジャッジ時間 | 3,496 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#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