結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2018-11-07 14:47:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 342 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-20 20:43:59 |
合計ジャッジ時間 | 1,703 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 15 |
ソースコード
n, k = map(int, input().split()) s = list(input()) l = [1] d = 1 for i in range(1, len(s)): if s[i-1] == '(' and s[i] == '(': d += 1 l.append(d) elif s[i-1] == ')' and s[i] == ')': d -= 1 l.append(d) else: l.append(d) x = l[k-1] y = [i+1 for i, j in enumerate(l) if j == x] print(y[-1])