結果

問題 No.451 575
ユーザー miraxialmiraxial
提出日時 2016-12-02 23:01:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 11,408 KB
実行使用メモリ 27,016 KB
最終ジャッジ日時 2023-08-22 13:44:07
合計ジャッジ時間 6,697 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,272 KB
testcase_01 AC 78 ms
15,140 KB
testcase_02 AC 77 ms
15,088 KB
testcase_03 AC 77 ms
15,116 KB
testcase_04 AC 77 ms
15,084 KB
testcase_05 AC 82 ms
15,208 KB
testcase_06 AC 94 ms
15,776 KB
testcase_07 AC 219 ms
27,016 KB
testcase_08 AC 78 ms
15,244 KB
testcase_09 AC 80 ms
15,456 KB
testcase_10 AC 114 ms
16,656 KB
testcase_11 AC 188 ms
18,692 KB
testcase_12 AC 222 ms
19,396 KB
testcase_13 AC 208 ms
19,552 KB
testcase_14 AC 79 ms
15,036 KB
testcase_15 AC 81 ms
15,280 KB
testcase_16 AC 93 ms
16,292 KB
testcase_17 AC 162 ms
18,280 KB
testcase_18 AC 159 ms
18,336 KB
testcase_19 AC 134 ms
17,772 KB
testcase_20 AC 84 ms
15,600 KB
testcase_21 AC 81 ms
15,352 KB
testcase_22 AC 77 ms
15,188 KB
testcase_23 AC 223 ms
19,308 KB
testcase_24 AC 164 ms
18,044 KB
testcase_25 AC 79 ms
15,156 KB
testcase_26 AC 78 ms
15,232 KB
testcase_27 AC 78 ms
15,028 KB
testcase_28 AC 79 ms
15,248 KB
testcase_29 AC 91 ms
15,780 KB
testcase_30 AC 165 ms
18,472 KB
testcase_31 AC 79 ms
15,272 KB
testcase_32 AC 129 ms
18,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:22: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n=gets.to_i
a=[]
n.times do |i|
  a<< gets.to_i
end
c=1
e=0
while true do
b=[]
b<< 2-c
(n/2).times do |i|
  b<< a[i*2]-b[i*2]
  b<< b[i*2+1]-a[i*2+1]
end
(n%2).times do
  b<< a[-1]-b[-1]
end
if b.all?{|i|i>0}
  puts n+1,b.*("\n")
  break
elsif e==1
  p -1
  break
end
c=1
(n+1).times do |i|
  c=b[i] if c>b[i]
end
e+=1
end
0