結果

問題 No.22 括弧の対応
ユーザー y_nakamura_CC2y_nakamura_CC2
提出日時 2018-09-15 01:28:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 7,932 KB
最終ジャッジ日時 2023-09-21 03:47:40
合計ジャッジ時間 1,470 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 15 ms
7,828 KB
testcase_03 AC 16 ms
7,752 KB
testcase_04 AC 16 ms
7,840 KB
testcase_05 AC 16 ms
7,760 KB
testcase_06 AC 16 ms
7,800 KB
testcase_07 WA -
testcase_08 AC 16 ms
7,788 KB
testcase_09 WA -
testcase_10 AC 16 ms
7,796 KB
testcase_11 AC 16 ms
7,788 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 15 ms
7,860 KB
testcase_16 AC 16 ms
7,932 KB
testcase_17 AC 16 ms
7,912 KB
testcase_18 AC 15 ms
7,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
S = input()

count = 0

if S[M-1] == "(":
    for i in range(M, N):
        if S[i] == ")" and count == 0:
            print (i+1)
            break
        elif S[i] ==")":
            count -= 1
        else:
            count += 1
            
else:
    for i in range(M-2, -1, -1):
        print("count", count, "i", i, S[i])
        if S[i] == "(" and count == 0:
            print (i+1)
            break
        elif S[i] =="(":
            count -= 1
        else:
            count += 1
0