結果

問題 No.451 575
ユーザー miraxialmiraxial
提出日時 2016-12-02 22:31:10
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 381 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 20,736 KB
最終ジャッジ日時 2024-05-09 19:02:01
合計ジャッジ時間 6,739 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,288 KB
testcase_01 AC 80 ms
12,160 KB
testcase_02 AC 79 ms
12,160 KB
testcase_03 AC 84 ms
12,160 KB
testcase_04 AC 84 ms
12,288 KB
testcase_05 AC 92 ms
12,416 KB
testcase_06 AC 102 ms
12,928 KB
testcase_07 AC 232 ms
20,736 KB
testcase_08 AC 82 ms
12,288 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 231 ms
18,048 KB
testcase_14 AC 84 ms
12,160 KB
testcase_15 AC 88 ms
12,416 KB
testcase_16 AC 98 ms
13,184 KB
testcase_17 AC 192 ms
18,688 KB
testcase_18 AC 157 ms
15,104 KB
testcase_19 AC 150 ms
16,384 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 82 ms
12,288 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 79 ms
12,160 KB
testcase_26 AC 83 ms
12,288 KB
testcase_27 AC 80 ms
12,416 KB
testcase_28 AC 79 ms
12,416 KB
testcase_29 AC 95 ms
12,800 KB
testcase_30 AC 194 ms
18,816 KB
testcase_31 AC 79 ms
12,416 KB
testcase_32 AC 134 ms
15,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:31: 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
b=[]
b<< 1
(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
c=0
n.times do |i|
  c+=b[i] if 1>b[i]
end
b=[]
b<< 1+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")
else
  p -1
end
0