結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2019-12-30 09:49:56 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,538 ms / 5,000 ms |
コード長 | 577 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-20 07:46:58 |
合計ジャッジ時間 | 5,702 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
input_list = list(map(int,input().split())) n, k = input_list s = input() s_list = list(s) len_s = len(s_list) comb_list = [] checked = 0 res = None while checked != n: close_index = s_list.index(')') open_index = None for i in range(close_index): if s_list[i] == '(': open_index = i if open_index == k - 1: res = close_index + 1 break elif close_index == k - 1: res = open_index + 1 break s_list[close_index] = 'x' s_list[open_index] = 'x' checked += 2 print(res)