結果

問題 No.451 575
ユーザー rlangevinrlangevin
提出日時 2023-09-15 12:28:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 85,836 KB
最終ジャッジ日時 2023-09-15 12:28:34
合計ジャッジ時間 6,489 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,076 KB
testcase_01 AC 72 ms
71,208 KB
testcase_02 AC 70 ms
71,208 KB
testcase_03 AC 71 ms
71,292 KB
testcase_04 AC 71 ms
71,204 KB
testcase_05 AC 84 ms
76,004 KB
testcase_06 AC 88 ms
76,408 KB
testcase_07 AC 160 ms
85,836 KB
testcase_08 AC 73 ms
71,060 KB
testcase_09 AC 77 ms
71,252 KB
testcase_10 AC 105 ms
77,140 KB
testcase_11 AC 127 ms
77,960 KB
testcase_12 AC 138 ms
78,060 KB
testcase_13 AC 141 ms
77,792 KB
testcase_14 AC 72 ms
71,120 KB
testcase_15 AC 84 ms
76,460 KB
testcase_16 AC 89 ms
76,400 KB
testcase_17 AC 116 ms
77,552 KB
testcase_18 AC 112 ms
77,744 KB
testcase_19 AC 106 ms
77,260 KB
testcase_20 AC 96 ms
76,732 KB
testcase_21 AC 82 ms
75,292 KB
testcase_22 AC 98 ms
71,204 KB
testcase_23 AC 137 ms
78,024 KB
testcase_24 AC 122 ms
77,888 KB
testcase_25 AC 71 ms
71,144 KB
testcase_26 AC 73 ms
71,244 KB
testcase_27 AC 72 ms
71,268 KB
testcase_28 AC 75 ms
71,264 KB
testcase_29 AC 90 ms
76,480 KB
testcase_30 AC 120 ms
77,504 KB
testcase_31 AC 72 ms
71,292 KB
testcase_32 AC 104 ms
78,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# a2 = b1 - a1
# a3 = a2 - b2 = - b2 + b1 - a1
# a4 = b3 - a3 = b3 + b2 - b1 + a1
# a5 = a4 - b4 = -b4 + b3 + b2 - b1 + a1
# a6 = b5 - a5

import sys
input = sys.stdin.readline

N = int(input())
ans = [0] * N
v = 0
now = 0
for i in range(N):
    b = int(input())
    if i % 2:
        now = now - b
    else:
        now = b - now
    ans[i] = now
    if 2 <= i % 4 <= 3:
        v = min(v, now - 1)

a = max(1, -v)
for i in range(N):
    if i % 4 <= 1:
        ans[i] -= a
    else:
        ans[i] += a
    if ans[i] <= 0:
        print(-1)
        exit()

print(N + 1)
print(a)
for a in ans:
    print(a)
0