結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
neko_the_shadow
|
| 提出日時 | 2016-12-18 16:00:22 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 121 ms / 5,000 ms |
| コード長 | 269 bytes |
| コンパイル時間 | 216 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-07-20 07:18:46 |
| 合計ジャッジ時間 | 3,006 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n Syntax OK
ソースコード
n, k = STDIN.gets.split.map(&:to_i)
tokens = STDIN.gets.chomp.chars
stack = []
tokens.each.with_index(1) do |token, i|
stack << i if token == "("
if token == ")"
j = stack.pop
if [i, j].include?(k)
puts i == k ? j : i
break
end
end
end
neko_the_shadow