結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2015-03-30 21:36:02 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 294 bytes |
コンパイル時間 | 63 ms |
コンパイル使用メモリ | 6,940 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2024-07-20 06:58:28 |
合計ジャッジ時間 | 1,011 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
N,K = map(int,raw_input().split(' ')) S = raw_input() s = [] i = 0 flag = False while not flag: while i < len(S) and S[i] == '(': s.append(i+1) i += 1 while i < len(S) and S[i] == ')': p = s.pop() if p == K or (i+1) == K: flag = True print i+1 if p == K else p break i += 1