結果

問題 No.1537 私の代わりに仕事やっといてください。
ユーザー 小野寺健小野寺健
提出日時 2021-11-15 09:30:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 429 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 46,792 KB
最終ジャッジ日時 2023-08-20 23:23:46
合計ジャッジ時間 2,587 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,080 KB
testcase_01 AC 81 ms
15,312 KB
testcase_02 AC 429 ms
46,792 KB
testcase_03 AC 81 ms
15,264 KB
testcase_04 AC 82 ms
15,336 KB
testcase_05 AC 81 ms
15,148 KB
testcase_06 AC 81 ms
15,160 KB
testcase_07 AC 85 ms
15,300 KB
testcase_08 AC 84 ms
15,288 KB
testcase_09 AC 89 ms
15,580 KB
testcase_10 AC 110 ms
17,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split(" ").map.with_index{|s, i| [s.to_i, i+1]}

top = true
ans = []

A.sort_by{|x, i| -x}.each {|x, i|
	if top then
		ans.unshift(i.to_s)
	else
		ans.push(i.to_s)
	end
	top = !top
}

i = ans.index("1")

puts (ans[i, N-i] + ans[0, i] + ["1"]).join(" ")
		
0