結果

問題 No.592 括弧の対応 (2)
ユーザー horiesinitihoriesiniti
提出日時 2018-03-14 07:10:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,179 ms / 5,000 ms
コード長 176 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 31,104 KB
最終ジャッジ日時 2024-05-04 00:24:03
合計ジャッジ時間 4,355 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,160 KB
testcase_01 AC 1,101 ms
27,776 KB
testcase_02 AC 1,179 ms
27,904 KB
testcase_03 AC 940 ms
31,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n=gets.to_i
s=gets.chomp
p2=1
arr=[]
ans=[]
s.chars{|e|
	if e=="("
		arr<<p2
	else
		p3=arr.pop
		ans<<[p3,p2]
		ans<<[p2,p3]
	end
	p2+=1
}
ans.sort!
ans.each{|e|
	puts e[1]	
}
0