結果

問題 No.258 回転寿司(2)
ユーザー suppy193suppy193
提出日時 2015-08-05 11:54:31
言語 Ruby
(3.4.1)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-11-06 18:51:02
合計ジャッジ時間 9,770 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 67
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.strip.to_i
v = gets.strip.split(' ').map(&:to_i)
total = [0, 0]
dish0 = []
dish1 = []
(0..v.length-1).each do |i|
	dish = dish0.clone
	dish0 = dish1.clone
	dish1 = dish.clone
	tmp = total[1] + v[i]
	if total[0] > total[1]
		total[1] = total[0]
	else
		dish1 = dish0.clone
	end
	total[0] = tmp
	dish0 << i + 1
	# print "#{dish0}, #{dish1}\n"
end
puts total.max
if total[0] > total[1]
	puts dish0.join(' ')
else
	puts dish1.join(' ')
end
0