結果

問題 No.592 括弧の対応 (2)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-14 07:10:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,062 ms / 5,000 ms
コード長 176 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 11,236 KB
実行使用メモリ 33,236 KB
最終ジャッジ日時 2023-08-16 16:33:09
合計ジャッジ時間 4,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,028 KB
testcase_01 AC 1,012 ms
32,696 KB
testcase_02 AC 1,062 ms
33,236 KB
testcase_03 AC 844 ms
31,620 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