結果

問題 No.451 575
ユーザー matsu7874matsu7874
提出日時 2016-12-02 01:01:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 12,356 KB
最終ジャッジ日時 2023-08-22 12:11:51
合計ジャッジ時間 6,654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,116 KB
testcase_01 AC 16 ms
8,276 KB
testcase_02 AC 16 ms
8,152 KB
testcase_03 AC 15 ms
8,248 KB
testcase_04 AC 15 ms
7,932 KB
testcase_05 AC 25 ms
8,468 KB
testcase_06 AC 49 ms
9,112 KB
testcase_07 AC 191 ms
12,248 KB
testcase_08 AC 16 ms
8,268 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 17 ms
7,852 KB
testcase_15 AC 22 ms
8,284 KB
testcase_16 AC 43 ms
8,820 KB
testcase_17 AC 194 ms
12,152 KB
testcase_18 AC 192 ms
12,300 KB
testcase_19 AC 132 ms
10,808 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 16 ms
8,304 KB
testcase_23 WA -
testcase_24 AC 543 ms
12,060 KB
testcase_25 WA -
testcase_26 AC 16 ms
7,768 KB
testcase_27 AC 18 ms
7,848 KB
testcase_28 AC 18 ms
7,840 KB
testcase_29 AC 33 ms
8,552 KB
testcase_30 AC 196 ms
12,356 KB
testcase_31 AC 15 ms
8,116 KB
testcase_32 AC 74 ms
9,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
b = [int(input()) for i in range(n)]

if b[0] == 1:
    print(-1)
    exit()
l = 1
r = b[0]-1
m = (l+r)//2
while l<r:
    ok = True
    a = [m]
    i = 0
    while i < n:
        if i%2 == 0:
            a.append(b[i] - a[i])
        elif i%2 == 1:
            a.append(a[i] - b[i])
        if a[-1] <= 0:
            ok = False
            break
        i += 1
    if ok:
        print(n+1)
        for v in a:
            print(v)
        exit()
    if i%2 == 0:
        l = m+1
    else:
        r = m-1
    m = (l+r)//2
print(-1)
0