結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2015-08-16 08:45:19 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 5,000 ms |
| コード長 | 342 bytes |
| コンパイル時間 | 65 ms |
| コンパイル使用メモリ | 7,040 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-20 07:03:25 |
| 合計ジャッジ時間 | 975 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
import sys
N,K = map(int, raw_input().split())
pare = raw_input()
stack = []
for i in range(N):
if (pare[i] == '('):
stack.append(["(", i + 1])
else:
pos = stack.pop()
if ((i + 1) == K):
print pos[1]
sys.exit(0)
if (pos[1] == K):
print i + 1
sys.exit(0)
togatoga