結果

問題 No.451 575
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-21 09:20:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,696 KB
最終ジャッジ日時 2024-05-01 18:19:10
合計ジャッジ時間 6,231 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 33 ms
10,752 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 29 ms
10,624 KB
testcase_05 AC 31 ms
11,008 KB
testcase_06 AC 36 ms
11,520 KB
testcase_07 AC 74 ms
14,720 KB
testcase_08 AC 30 ms
10,880 KB
testcase_09 AC 30 ms
11,008 KB
testcase_10 AC 94 ms
16,000 KB
testcase_11 AC 229 ms
25,216 KB
testcase_12 AC 280 ms
29,696 KB
testcase_13 AC 281 ms
29,696 KB
testcase_14 AC 29 ms
10,624 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 43 ms
11,392 KB
testcase_17 AC 165 ms
14,592 KB
testcase_18 AC 71 ms
14,720 KB
testcase_19 AC 88 ms
13,312 KB
testcase_20 AC 39 ms
11,520 KB
testcase_21 AC 31 ms
10,880 KB
testcase_22 AC 29 ms
10,752 KB
testcase_23 AC 287 ms
29,696 KB
testcase_24 AC 174 ms
20,992 KB
testcase_25 AC 30 ms
10,752 KB
testcase_26 AC 30 ms
10,752 KB
testcase_27 AC 31 ms
10,752 KB
testcase_28 AC 33 ms
10,752 KB
testcase_29 AC 47 ms
11,136 KB
testcase_30 AC 169 ms
14,720 KB
testcase_31 AC 31 ms
10,624 KB
testcase_32 AC 45 ms
11,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
U = 10 ** 18

N = int(input())
B = [int(input()) for _ in range(N)]

amin = 1
amax = U
for i, b in enumerate(B, 1):
    if i % 2 == 1:
        x = max(1, b - amax)
        y = b - amin
    else:
        x = max(1, amin - b)
        y = amax - b
    if x > y:
        print(-1)
        exit()
    amin = x
    amax = y

ans = [amin]
for i, b in reversed(list(enumerate(B, 1))):
    if i % 2 == 1:
        ans.append(b - ans[-1])
    else:
        ans.append(b + ans[-1])


print(N+1)
print(*ans[::-1], sep="\n")
0