結果

問題 No.451 575
ユーザー kimiyukikimiyuki
提出日時 2016-12-02 02:37:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 399 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 20,740 KB
最終ジャッジ日時 2023-08-22 13:22:47
合計ジャッジ時間 6,748 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,836 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 15 ms
7,756 KB
testcase_03 AC 15 ms
7,820 KB
testcase_04 AC 14 ms
7,796 KB
testcase_05 AC 32 ms
8,568 KB
testcase_06 AC 70 ms
9,916 KB
testcase_07 AC 309 ms
17,760 KB
testcase_08 AC 15 ms
7,908 KB
testcase_09 AC 18 ms
8,300 KB
testcase_10 AC 109 ms
11,140 KB
testcase_11 AC 300 ms
17,136 KB
testcase_12 AC 399 ms
20,056 KB
testcase_13 AC 398 ms
20,056 KB
testcase_14 AC 16 ms
7,972 KB
testcase_15 AC 25 ms
8,336 KB
testcase_16 AC 61 ms
9,332 KB
testcase_17 AC 312 ms
16,084 KB
testcase_18 AC 311 ms
16,216 KB
testcase_19 AC 209 ms
13,132 KB
testcase_20 AC 30 ms
8,708 KB
testcase_21 AC 19 ms
8,288 KB
testcase_22 AC 15 ms
7,828 KB
testcase_23 AC 396 ms
20,740 KB
testcase_24 AC 236 ms
14,376 KB
testcase_25 AC 15 ms
7,848 KB
testcase_26 AC 15 ms
7,836 KB
testcase_27 AC 16 ms
7,856 KB
testcase_28 AC 19 ms
8,244 KB
testcase_29 AC 45 ms
9,068 KB
testcase_30 AC 310 ms
16,836 KB
testcase_31 AC 15 ms
7,804 KB
testcase_32 AC 115 ms
11,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
n = int(input())
b = [ int(input()) for _ in range(n) ]
def f(a1):
    a = [ None ] * (n+1)
    a[0] = a1
    for i in range(n):
        if (i+1 + 1) % 2 == 0:
            a[i+1] = - a[i] + b[i]
        else:
            a[i+1] = a[i] - b[i]
    return a
lower = 1
upper = 10**18
a = f(0)
for i in range(n+1):
    if ((i+1) // 2) % 2 == 0:
        lower = max(lower, 1      - a[i])
        upper = min(upper, 10**18 - a[i])
    else:
        lower = max(lower, a[i] - 10**18)
        upper = min(upper, a[i] - 1     )
if lower <= upper:
    print(n+1)
    for ai in f(lower):
        print(ai)
else:
    print(-1)
0