結果

問題 No.451 575
ユーザー koba-e964koba-e964
提出日時 2016-12-03 00:51:46
言語 Ruby
(3.3.0)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 11,588 KB
実行使用メモリ 23,440 KB
最終ジャッジ日時 2023-08-22 13:46:04
合計ジャッジ時間 6,792 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,356 KB
testcase_01 AC 78 ms
15,128 KB
testcase_02 AC 79 ms
15,280 KB
testcase_03 AC 79 ms
15,244 KB
testcase_04 AC 79 ms
15,312 KB
testcase_05 AC 85 ms
15,456 KB
testcase_06 AC 95 ms
15,424 KB
testcase_07 AC 243 ms
23,440 KB
testcase_08 AC 79 ms
15,124 KB
testcase_09 AC 81 ms
15,380 KB
testcase_10 AC 129 ms
16,120 KB
testcase_11 AC 229 ms
17,008 KB
testcase_12 AC 276 ms
17,384 KB
testcase_13 AC 274 ms
17,512 KB
testcase_14 AC 78 ms
15,168 KB
testcase_15 AC 82 ms
15,420 KB
testcase_16 AC 92 ms
15,960 KB
testcase_17 AC 165 ms
17,640 KB
testcase_18 AC 166 ms
17,540 KB
testcase_19 AC 137 ms
17,004 KB
testcase_20 AC 87 ms
15,968 KB
testcase_21 AC 81 ms
15,360 KB
testcase_22 AC 78 ms
15,268 KB
testcase_23 AC 276 ms
17,520 KB
testcase_24 AC 196 ms
16,784 KB
testcase_25 AC 78 ms
15,244 KB
testcase_26 AC 81 ms
15,356 KB
testcase_27 AC 82 ms
15,144 KB
testcase_28 AC 80 ms
15,464 KB
testcase_29 AC 89 ms
15,756 KB
testcase_30 AC 166 ms
17,328 KB
testcase_31 AC 78 ms
15,040 KB
testcase_32 AC 134 ms
17,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:32: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

n=gets.to_i
b=Array.new(n)
for i in 0...n
  b[i]=gets.to_i
end
a=Array.new(n+1)
a[0]=0
for i in 0...n
  if i%2==0
    a[i+1]=b[i]-a[i]
  else
    a[i+1]=a[i]-b[i]
  end
end
lim=10**18
xl=1-a[0]
xh=lim-a[0]
yl=a[1]-lim
yh=a[1]-1
for i in 0..n
  if i%4==0||i%4==3
    xl=[1-a[i],xl].max
    xh=[lim-a[i],xh].min
  else
    yl=[a[i]-lim,yl].max
    yh=[a[i]-1,yh].min
  end
end
xl=[xl,yl].max
xh=[xh,yh].min
if xl>xh
  puts -1
else
  puts n+1
  for i in 0..n
    puts a[i]+(if i%4==0||i%4==3 then xl else -xl end)
  end
end
0