結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-31 19:37:22 |
| 言語 | Ruby (4.0.2) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 5,000 ms |
| コード長 | 307 bytes |
| 記録 | |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 8,960 KB |
| 実行使用メモリ | 29,696 KB |
| 最終ジャッジ日時 | 2026-04-02 21:54:01 |
| 合計ジャッジ時間 | 1,778 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n Syntax OK
ソースコード
n, k = gets.split.map(&:to_i)
s = gets
stack = []
ans = []
s.each_char.with_index do |c, idx|
stack.push(idx) if c == "("
ans = [stack.pop + 1, idx + 1] if c == ")"
if ans[0] == k
puts ans[1]
exit 0
end
if ans[1] == k
puts ans[0]
exit 0
end
end