結果

問題 No.22 括弧の対応
ユーザー AAAR SalmonAAAR Salmon
提出日時 2021-05-22 18:35:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 407 bytes
コンパイル時間 2,432 ms
コンパイル使用メモリ 81,960 KB
実行使用メモリ 55,808 KB
最終ジャッジ日時 2024-04-18 23:27:20
合計ジャッジ時間 2,228 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
55,040 KB
testcase_01 AC 47 ms
54,912 KB
testcase_02 AC 47 ms
55,552 KB
testcase_03 AC 46 ms
55,552 KB
testcase_04 AC 52 ms
55,168 KB
testcase_05 AC 49 ms
55,168 KB
testcase_06 AC 48 ms
55,552 KB
testcase_07 AC 49 ms
55,296 KB
testcase_08 AC 49 ms
55,168 KB
testcase_09 AC 48 ms
55,040 KB
testcase_10 AC 49 ms
55,424 KB
testcase_11 AC 51 ms
55,040 KB
testcase_12 AC 48 ms
55,552 KB
testcase_13 AC 46 ms
55,040 KB
testcase_14 AC 48 ms
55,808 KB
testcase_15 AC 48 ms
54,912 KB
testcase_16 AC 44 ms
54,912 KB
testcase_17 AC 47 ms
55,040 KB
testcase_18 AC 47 ms
55,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
from math import sin, cos, tan
from functools import reduce
from collections import deque
import heapq
sys.setrecursionlimit(1000000)
intm1 = lambda x:int(x)-1

N, K = map(int,input().split())
K -= 1
S = input()

cnt = 1 if S[K] == '(' else -1
for i in range(K + 1, N, 1) if S[K] == '(' else range(K - 1, -1, -1):
	cnt += 1 if S[i] == '(' else -1
	if cnt == 0:
		print(i + 1)
		break
0