結果

問題 No.22 括弧の対応
ユーザー gahougahou
提出日時 2016-11-16 18:34:22
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 231 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 7,092 KB
実行使用メモリ 6,212 KB
最終ジャッジ日時 2023-08-17 07:32:05
合計ジャッジ時間 1,163 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,884 KB
testcase_01 AC 10 ms
6,092 KB
testcase_02 AC 11 ms
5,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 11 ms
5,932 KB
testcase_18 AC 10 ms
5,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,raw_input().split())
S=raw_input()
t={}
e=[0]*N
k=0
for i in xrange(N):
  if S[i]=="(":
    t[k]=[i]
    e[i]=k
    k+=1
  else:
    t[k-1].append(i)
    k-=1
    e[i]=k
a=t[e[K-1]]
print a[1]+1 if a[0]==K-1 else a[0]+1
0