結果
| 問題 | No.22 括弧の対応 |
| ユーザー |
|
| 提出日時 | 2022-02-19 11:43:46 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 40 ms / 5,000 ms |
| + 422µs | |
| コード長 | 482 bytes |
| 記録 | |
| コンパイル時間 | 422 ms |
| コンパイル使用メモリ | 64,256 KB |
| 実行使用メモリ | 58,036 KB |
| 最終ジャッジ日時 | 2026-11-10 23:16:00 |
| 合計ジャッジ時間 | 2,712 ms |
|
ジャッジサーバーID (参考情報) |
judge7_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#yukicoder No.22 括弧の対応
N, K = map(int, input().split())
S = input()
d = []
cnt = 0
for i in range(N):
if S[i] == "(":
cnt += 1
else:
cnt -= 1
d.append(cnt)
i = K - 1
if S[i] == ")":
while True:
i -= 1
if d[i] == d[K - 1] + 1 and S[i] == "(":
print(i + 1)
break
else:
while True:
i += 1
if d[i] == d[K - 1] - 1 and S[i] == ")":
print(i + 1)
break