結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2016-01-06 15:21:59 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 84 ms / 5,000 ms |
コード長 | 228 bytes |
コンパイル時間 | 57 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-07-20 07:07:03 |
合計ジャッジ時間 | 2,308 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n Syntax OK
ソースコード
n, k = gets.split.map(&:to_i) cs = " #{gets.chomp}" idxs = cs[k] == "(" ? k.upto(cs.length) : k.downto(1) count = 0 idxs.each do |idx| count += cs[idx] == cs[k] ? +1 : -1 if count == 0 then puts idx break end end