結果

問題 No.451 575
ユーザー nebukuro09nebukuro09
提出日時 2016-12-02 00:48:36
言語 Python2
(2.7.18)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 6,676 KB
実行使用メモリ 12,316 KB
最終ジャッジ日時 2023-08-22 12:43:34
合計ジャッジ時間 6,068 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,008 KB
testcase_01 AC 12 ms
5,996 KB
testcase_02 AC 11 ms
6,120 KB
testcase_03 AC 11 ms
5,992 KB
testcase_04 AC 11 ms
6,192 KB
testcase_05 AC 22 ms
6,340 KB
testcase_06 AC 47 ms
6,616 KB
testcase_07 AC 209 ms
9,004 KB
testcase_08 AC 11 ms
6,076 KB
testcase_09 AC 13 ms
6,024 KB
testcase_10 AC 76 ms
7,452 KB
testcase_11 AC 207 ms
10,776 KB
testcase_12 AC 271 ms
12,160 KB
testcase_13 AC 277 ms
12,316 KB
testcase_14 AC 11 ms
6,044 KB
testcase_15 AC 17 ms
6,280 KB
testcase_16 AC 42 ms
6,560 KB
testcase_17 AC 206 ms
9,008 KB
testcase_18 AC 204 ms
9,108 KB
testcase_19 AC 143 ms
8,052 KB
testcase_20 AC 21 ms
6,220 KB
testcase_21 AC 14 ms
6,044 KB
testcase_22 AC 11 ms
6,048 KB
testcase_23 AC 274 ms
12,200 KB
testcase_24 AC 164 ms
8,768 KB
testcase_25 AC 11 ms
5,980 KB
testcase_26 AC 11 ms
6,160 KB
testcase_27 AC 12 ms
5,984 KB
testcase_28 AC 13 ms
6,208 KB
testcase_29 AC 30 ms
6,368 KB
testcase_30 AC 203 ms
9,144 KB
testcase_31 AC 11 ms
6,040 KB
testcase_32 AC 81 ms
6,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
b = [int(raw_input()) for _ in xrange(N)]
upper = 10 ** 18 + 1
lower = 0
x = 0
for i in xrange(N):
    if i % 4 == 0:
        x += b[i]
        upper = min(upper, x)
    elif i % 4 == 1:
        x -= b[i]
        upper = min(upper, x)
    elif i % 4 == 2:
        x -= b[i]
        lower = max(lower, x)
    else:
        x += b[i]
        lower = max(lower, x)

if upper - lower <= 1:
    print -1
else:
    a = [0 for _ in xrange(N+1)]
    a[0] = lower + 1
    for i in xrange(1, N+1):
        a[i] = b[i-1] - a[i-1] if i % 2 == 1 else a[i-1] - b[i-1]
    print N+1
    for x in a:
        print x
0