結果

問題 No.999 てん vs. ほむ
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-07 15:28:23
言語 Ruby
(3.3.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 239 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 30,468 KB
最終ジャッジ日時 2023-09-18 22:42:22
合計ジャッジ時間 7,067 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,272 KB
testcase_01 AC 84 ms
15,292 KB
testcase_02 AC 84 ms
15,244 KB
testcase_03 AC 83 ms
15,136 KB
testcase_04 AC 85 ms
15,292 KB
testcase_05 AC 85 ms
15,248 KB
testcase_06 AC 88 ms
15,128 KB
testcase_07 AC 83 ms
15,244 KB
testcase_08 AC 89 ms
15,344 KB
testcase_09 AC 193 ms
29,212 KB
testcase_10 AC 120 ms
18,972 KB
testcase_11 AC 108 ms
17,620 KB
testcase_12 AC 135 ms
21,172 KB
testcase_13 AC 205 ms
30,468 KB
testcase_14 AC 200 ms
30,220 KB
testcase_15 AC 201 ms
30,228 KB
testcase_16 AC 203 ms
30,408 KB
testcase_17 AC 192 ms
28,892 KB
testcase_18 AC 192 ms
28,668 KB
testcase_19 AC 191 ms
28,744 KB
testcase_20 AC 190 ms
28,736 KB
testcase_21 AC 201 ms
30,252 KB
testcase_22 AC 203 ms
29,908 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
xs=gets.split(" ").map{|e| e.to_i}
ls=[0]
rs=[0]
s=0
n.times{|i|
	s+=xs[i*2]-xs[i*2+1]
	ls<<s
}
s=0
(n-1).downto(0){|i|
	s+=xs[i*2+1]-xs[i*2]
	rs.unshift(s)
}
ans=ls[0]+rs[0]
0.upto(n){|i|
	ans=[ans,ls[i]+rs[i]].max
}
puts ans
0