結果

問題 No.451 575
ユーザー nanaenanae
提出日時 2017-04-07 10:07:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 841 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 12,424 KB
最終ジャッジ日時 2023-09-22 23:50:03
合計ジャッジ時間 6,225 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,820 KB
testcase_01 AC 15 ms
7,816 KB
testcase_02 AC 16 ms
7,852 KB
testcase_03 AC 15 ms
7,808 KB
testcase_04 WA -
testcase_05 AC 22 ms
8,468 KB
testcase_06 AC 36 ms
9,012 KB
testcase_07 AC 125 ms
12,328 KB
testcase_08 AC 16 ms
7,776 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 16 ms
7,816 KB
testcase_15 AC 20 ms
8,316 KB
testcase_16 AC 33 ms
8,784 KB
testcase_17 AC 124 ms
12,264 KB
testcase_18 AC 125 ms
12,328 KB
testcase_19 AC 89 ms
10,708 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 17 ms
7,864 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 16 ms
7,860 KB
testcase_27 AC 16 ms
7,864 KB
testcase_28 AC 17 ms
8,288 KB
testcase_29 AC 27 ms
8,572 KB
testcase_30 AC 124 ms
12,224 KB
testcase_31 AC 16 ms
7,852 KB
testcase_32 AC 52 ms
9,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

inf = 10**9 + 1

def solve():
    n = int(input())

    a_min = 1
    a_max = 10**18
    v = 0

    B = []

    for i in range(n):
        b = int(sys.stdin.readline().rstrip())
        B.append(b)

        if i & 1:
            v -= b
        else:
            v += b

        if (i >> 1) & 1:
            a_max = min(a_max, 10**18 - v)
            a_min = max(a_min, 1 - v)
        else:
            a_max = min(a_max, v - 1)
            a_min = max(a_min, v - 10**18)
            
    # print(a_min, a_max)

    if a_min > a_max:
        print(-1)
        return

    a = [0] * (n + 1)

    a[0] = a_min

    for i in range(1, n + 1):
        if i & 1:
            a[i] = B[i - 1] - a[i - 1]
        else:
            a[i] = a[i - 1] - B[i - 1]

    print(n + 1)
    print(*a, sep='\n')

if __name__ == '__main__':
    solve()
0