結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
torus711
|
| 提出日時 | 2017-07-01 14:20:10 |
| 言語 | Ruby (4.0.2) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 5,000 ms |
| コード長 | 312 bytes |
| 記録 | |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 8,832 KB |
| 実行使用メモリ | 30,592 KB |
| 最終ジャッジ日時 | 2026-04-02 21:53:17 |
| 合計ジャッジ時間 | 1,773 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
Syntax OK
ソースコード
N, K = gets.split.map( &:to_i )
S = gets
stack = Array.new
corresponds = Array.new( N )
S.split( "" ).each_with_index do | c, i |
if c == '(' then
stack.push( i )
elsif c == ')' # damn '\n' !
corresponds[i] = stack.last
corresponds[ stack.last ] = i
stack.pop
end
end
puts corresponds[ K - 1 ] + 1
torus711