結果

問題 No.451 575
ユーザー maspymaspy
提出日時 2020-03-07 08:11:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 885 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 36,436 KB
最終ジャッジ日時 2024-04-22 12:16:52
合計ジャッジ時間 7,723 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,496 KB
testcase_01 AC 28 ms
10,496 KB
testcase_02 WA -
testcase_03 AC 30 ms
10,496 KB
testcase_04 AC 28 ms
10,624 KB
testcase_05 AC 36 ms
11,392 KB
testcase_06 AC 55 ms
13,160 KB
testcase_07 AC 189 ms
26,048 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 242 ms
35,056 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 27 ms
10,624 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 28 ms
10,624 KB
testcase_26 AC 28 ms
10,496 KB
testcase_27 AC 28 ms
10,752 KB
testcase_28 WA -
testcase_29 AC 42 ms
11,904 KB
testcase_30 WA -
testcase_31 AC 27 ms
10,624 KB
testcase_32 AC 81 ms
15,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
N, *B = map(int, read().split())

# %%
A0 = [0] * (N + 1)
A1 = [1] + [0] * N

for i, x in enumerate(B):
    if i % 2 == 0:
        A0[i + 1] = x - A0[i]
        A1[i + 1] = x - A1[i]
    else:
        A0[i + 1] = A0[i] - x
        A1[i + 1] = A1[i] - x


# %%
U = 10 ** 18
left = 1
right = U
for x, y in zip(A0, A1):
    dx = y - x
    if dx == 1:
        L = -x
        R = U - x
    else:
        L = x - U
        R = x
    if left < L:
        left = L
    if right > R:
        right = R


# %%
if left > right:
    print(-1)
    exit()

# %%
A = [0] * (N + 1)
A[0] = left
for i, x in enumerate(B):
    if i % 2 == 0:
        A[i + 1] = x - A[i]
    else:
        A[i + 1] = A[i] - x

print(len(A))
print('\n'.join(map(str, A)))
0