結果

問題 No.451 575
ユーザー maimai
提出日時 2016-12-02 00:19:19
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 304 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-05-09 16:55:22
合計ジャッジ時間 6,216 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
12,160 KB
testcase_01 AC 71 ms
12,288 KB
testcase_02 AC 74 ms
12,160 KB
testcase_03 AC 74 ms
12,032 KB
testcase_04 AC 71 ms
12,032 KB
testcase_05 AC 76 ms
12,416 KB
testcase_06 AC 83 ms
12,416 KB
testcase_07 AC 123 ms
14,080 KB
testcase_08 AC 74 ms
12,288 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 231 ms
13,824 KB
testcase_14 AC 73 ms
12,288 KB
testcase_15 AC 82 ms
12,288 KB
testcase_16 AC 89 ms
12,800 KB
testcase_17 AC 122 ms
13,824 KB
testcase_18 AC 121 ms
13,952 KB
testcase_19 AC 108 ms
13,312 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 73 ms
12,288 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 75 ms
12,288 KB
testcase_26 AC 74 ms
12,160 KB
testcase_27 AC 73 ms
12,288 KB
testcase_28 AC 74 ms
12,288 KB
testcase_29 AC 78 ms
12,288 KB
testcase_30 AC 121 ms
13,952 KB
testcase_31 AC 73 ms
12,160 KB
testcase_32 AC 96 ms
12,672 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i

data = Array.new(n)
result = Array.new(n+1)

n.times{|i| data[i] = gets.to_i}

b = 1
result[0] = 1
n.times{|i|
    b = result[i+1] = (data[i]-b) if i%2==0
    b = result[i+1] = (b-data[i]) if i%2==1
    if (b<=0)
        puts "-1";exit
    end
}

puts n+1
result.each{|e| puts e}


    

0