結果

問題 No.22 括弧の対応
ユーザー _KingdomOfMoray_KingdomOfMoray
提出日時 2019-12-30 09:49:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,019 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,608 KB
実行使用メモリ 8,304 KB
最終ジャッジ日時 2023-09-27 13:44:22
合計ジャッジ時間 4,242 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,860 KB
testcase_01 AC 15 ms
7,972 KB
testcase_02 AC 15 ms
7,976 KB
testcase_03 AC 314 ms
7,860 KB
testcase_04 AC 77 ms
7,852 KB
testcase_05 AC 53 ms
7,864 KB
testcase_06 AC 393 ms
8,208 KB
testcase_07 AC 76 ms
8,196 KB
testcase_08 AC 20 ms
7,884 KB
testcase_09 AC 327 ms
7,904 KB
testcase_10 AC 32 ms
8,304 KB
testcase_11 AC 62 ms
7,772 KB
testcase_12 AC 236 ms
7,788 KB
testcase_13 AC 1,019 ms
8,264 KB
testcase_14 AC 19 ms
7,868 KB
testcase_15 AC 235 ms
8,204 KB
testcase_16 AC 395 ms
8,204 KB
testcase_17 AC 14 ms
7,868 KB
testcase_18 AC 13 ms
7,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0