結果
問題 | No.22 括弧の対応 |
ユーザー |
|
提出日時 | 2016-03-07 00:30:24 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 115 ms / 5,000 ms |
コード長 | 243 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-07-20 07:09:48 |
合計ジャッジ時間 | 2,806 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
Main.rb:5: warning: assigned but unused variable - b Syntax OK
ソースコード
n,k = gets.split.map(&:to_i) s = gets.chomp hash = Hash.new() a = [] b = [] n.times{|i| if s[i] == '(' a.push(i + 1) else hash[a.pop] = i + 1 end } if s[k - 1] == '(' p hash[k] else p hash.invert[k] end