結果

問題 No.451 575
ユーザー ヒッキープログラミングするスレ GitHub ガチヒッキープログラミングするスレ GitHub ガチ
提出日時 2016-12-02 23:59:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 7,980 KB
最終ジャッジ日時 2023-08-22 13:24:15
合計ジャッジ時間 4,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,980 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
b = [0] + [int(input()) for _ in range(n)]

def f(a1):
    a2 = b[1] - a1
    a = [0, a1, a2]
    for k in range(3, n + 2):
        t = 0
        if k % 2 == 0:
            t = b[k - 2] + b[k - 1] - a[k - 2]
            if t < 0 or t > 10 ** 18:
                return [1]
        else:
            t = b[k - 2] - b[k - 1] - a[k - 2]
            if t < 0 or t > 10 ** 18:
                return [-1]
        a.append(t)
    return a

g = b[1] - 1
l = 1

while l < g:
    m = (l + g) // 2
    ans = f(m)
    if len(ans) > 1:
        print(n + 1, *ans[1:], sep='\n')
        break
    elif ans[0] < 0:
        g = m
    else:
        l = m
0