結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
torus711
|
| 提出日時 | 2017-07-01 14:20:10 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 88 ms / 5,000 ms |
| コード長 | 312 bytes |
| コンパイル時間 | 166 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-07-20 07:24:45 |
| 合計ジャッジ時間 | 2,369 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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