結果

問題 No.451 575
ユーザー face4face4
提出日時 2019-10-17 20:51:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 355 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 12,296 KB
最終ジャッジ日時 2023-09-07 06:13:33
合計ジャッジ時間 7,578 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,888 KB
testcase_01 AC 16 ms
7,888 KB
testcase_02 AC 15 ms
8,156 KB
testcase_03 AC 16 ms
7,844 KB
testcase_04 AC 16 ms
8,088 KB
testcase_05 AC 30 ms
8,528 KB
testcase_06 AC 61 ms
8,820 KB
testcase_07 AC 255 ms
12,296 KB
testcase_08 AC 17 ms
7,848 KB
testcase_09 AC 18 ms
7,940 KB
testcase_10 AC 99 ms
9,208 KB
testcase_11 AC 271 ms
11,248 KB
testcase_12 AC 347 ms
12,140 KB
testcase_13 AC 349 ms
12,064 KB
testcase_14 AC 16 ms
8,260 KB
testcase_15 AC 24 ms
8,452 KB
testcase_16 AC 55 ms
8,828 KB
testcase_17 AC 257 ms
12,168 KB
testcase_18 AC 255 ms
12,140 KB
testcase_19 AC 175 ms
10,876 KB
testcase_20 AC 29 ms
8,388 KB
testcase_21 AC 19 ms
7,832 KB
testcase_22 AC 16 ms
7,840 KB
testcase_23 AC 355 ms
11,988 KB
testcase_24 AC 209 ms
9,428 KB
testcase_25 AC 16 ms
7,900 KB
testcase_26 AC 15 ms
8,096 KB
testcase_27 AC 17 ms
8,288 KB
testcase_28 AC 19 ms
8,248 KB
testcase_29 AC 40 ms
8,544 KB
testcase_30 AC 262 ms
12,148 KB
testcase_31 AC 16 ms
8,256 KB
testcase_32 AC 98 ms
9,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
b = [int(input()) for i in range(n)]
low, high = 1, 10**18
sign = 1    # sign of k
acc = 0
for i in range(n):
    if i%2 == 0:
        acc *= -1
        sign *= -1
        acc += b[i]
    else:
        acc -= b[i]
    
    if sign == 1:
        low = max(low, 1-acc)
    else:
        high = min(high, acc-1)

if low > high:
    print(-1)
    exit()

print(n+1)
print(low)
for i in range(n):
    low = b[i]-low if i%2 == 0 else low-b[i]
    print(low)
0