結果
問題 | No.22 括弧の対応 |
ユーザー |
|
提出日時 | 2021-02-10 11:35:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 5,000 ms |
コード長 | 327 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 82,232 KB |
実行使用メモリ | 61,440 KB |
最終ジャッジ日時 | 2024-07-07 21:36:43 |
合計ジャッジ時間 | 1,717 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
N,K = map(int,input().split()) S = list(input()) ls = [] pair = [-1]*(N) for i in range(N): ls.append((S[i],i)) if len(ls) >= 2: if ls[-1][0] == ')' and ls[-2][0] == '(': pair[ls[-1][1]] = ls[-2][1] pair[ls[-2][1]] = ls[-1][1] ls.pop() ls.pop() print(pair[K-1]+1)