結果

問題 No.451 575
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-12-26 00:01:17
言語 Python2
(2.7.18)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 6,640 KB
実行使用メモリ 21,160 KB
最終ジャッジ日時 2023-08-22 14:25:35
合計ジャッジ時間 5,248 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,936 KB
testcase_01 AC 11 ms
5,852 KB
testcase_02 AC 11 ms
5,952 KB
testcase_03 AC 11 ms
6,048 KB
testcase_04 AC 11 ms
5,960 KB
testcase_05 AC 21 ms
6,172 KB
testcase_06 AC 46 ms
6,416 KB
testcase_07 AC 213 ms
8,936 KB
testcase_08 AC 10 ms
5,844 KB
testcase_09 AC 12 ms
6,024 KB
testcase_10 AC 69 ms
9,476 KB
testcase_11 AC 191 ms
17,412 KB
testcase_12 AC 246 ms
21,156 KB
testcase_13 AC 255 ms
21,120 KB
testcase_14 AC 11 ms
5,848 KB
testcase_15 AC 17 ms
5,940 KB
testcase_16 AC 41 ms
6,408 KB
testcase_17 AC 196 ms
8,904 KB
testcase_18 AC 203 ms
9,004 KB
testcase_19 AC 136 ms
7,920 KB
testcase_20 AC 19 ms
6,344 KB
testcase_21 AC 13 ms
6,004 KB
testcase_22 AC 11 ms
5,932 KB
testcase_23 AC 249 ms
21,160 KB
testcase_24 AC 149 ms
14,052 KB
testcase_25 AC 11 ms
5,844 KB
testcase_26 AC 10 ms
5,952 KB
testcase_27 AC 11 ms
5,880 KB
testcase_28 AC 12 ms
5,844 KB
testcase_29 AC 30 ms
6,268 KB
testcase_30 AC 201 ms
8,972 KB
testcase_31 AC 10 ms
5,848 KB
testcase_32 AC 76 ms
6,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
n = int(raw_input())
b = [int(raw_input()) for _ in xrange(n)]
lo, hi = 1, 10**18
for i in xrange(n):
    if i & 1:
        lo, hi = max(lo - b[i], 1), hi - b[i]
    else:
        lo, hi = max(b[i] - hi, 1), b[i] - lo
if lo > hi:
    print -1
    exit(0)
a = [None] * n + [lo]
for i in reversed(xrange(n)):
    if i & 1:
        a[i] = b[i] + a[i+1]
    else:
        a[i] = b[i] - a[i+1]
print n + 1
print '\n'.join(map(str, a))
0