結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2019-06-06 10:49:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 322 bytes |
コンパイル時間 | 91 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-09-25 02:36:58 |
合計ジャッジ時間 | 1,471 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 10 RE * 5 |
ソースコード
n, k = map(int, input().split()) s = list(input()) x = 1 l = [] for i in range(n): if s[i] == '(': l.append(x) x += 1 elif s[i] == ')': x -= 1 l.append(x) y = l[k-1] if s[k-1] == '(': z = l[y:].index(y) print(y + z+1) else: z = l[:y].index(y) print(z+1)