結果

問題 No.451 575
ユーザー miraxialmiraxial
提出日時 2016-12-02 22:54:51
言語 Ruby
(3.2.2)
結果
AC  
実行時間 638 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 11,592 KB
実行使用メモリ 38,916 KB
最終ジャッジ日時 2023-08-22 13:43:10
合計ジャッジ時間 8,417 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,160 KB
testcase_01 AC 80 ms
15,164 KB
testcase_02 AC 80 ms
15,136 KB
testcase_03 AC 82 ms
15,020 KB
testcase_04 AC 81 ms
15,180 KB
testcase_05 AC 94 ms
16,012 KB
testcase_06 AC 123 ms
16,984 KB
testcase_07 AC 638 ms
38,916 KB
testcase_08 AC 80 ms
15,356 KB
testcase_09 AC 81 ms
15,508 KB
testcase_10 AC 118 ms
16,648 KB
testcase_11 AC 193 ms
18,968 KB
testcase_12 AC 228 ms
19,564 KB
testcase_13 AC 209 ms
19,188 KB
testcase_14 AC 80 ms
15,176 KB
testcase_15 AC 90 ms
15,740 KB
testcase_16 AC 120 ms
17,356 KB
testcase_17 AC 329 ms
25,656 KB
testcase_18 AC 309 ms
25,612 KB
testcase_19 AC 229 ms
22,036 KB
testcase_20 AC 89 ms
15,808 KB
testcase_21 AC 82 ms
15,152 KB
testcase_22 AC 80 ms
15,144 KB
testcase_23 AC 233 ms
19,452 KB
testcase_24 AC 168 ms
18,048 KB
testcase_25 AC 80 ms
15,336 KB
testcase_26 AC 81 ms
15,312 KB
testcase_27 AC 84 ms
15,068 KB
testcase_28 AC 83 ms
15,508 KB
testcase_29 AC 104 ms
16,728 KB
testcase_30 AC 332 ms
25,428 KB
testcase_31 AC 79 ms
15,304 KB
testcase_32 AC 271 ms
21,652 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==10
  p -1
  break
end
c=1
(n+1).times do |i|
  c=b[i] if c>b[i]
end
e+=1
end
0