結果

問題 No.451 575
ユーザー ryusukeryusuke
提出日時 2023-07-09 19:01:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 12,968 KB
最終ジャッジ日時 2023-09-30 22:36:12
合計ジャッジ時間 6,766 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 27 ms
8,504 KB
testcase_06 AC 50 ms
9,124 KB
testcase_07 AC 191 ms
12,936 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 16 ms
8,116 KB
testcase_15 AC 22 ms
8,464 KB
testcase_16 AC 47 ms
8,768 KB
testcase_17 AC 190 ms
12,952 KB
testcase_18 AC 193 ms
12,808 KB
testcase_19 AC 129 ms
11,268 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 16 ms
8,116 KB
testcase_27 AC 16 ms
8,156 KB
testcase_28 AC 18 ms
8,324 KB
testcase_29 AC 34 ms
8,592 KB
testcase_30 AC 193 ms
12,828 KB
testcase_31 WA -
testcase_32 AC 75 ms
9,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# verification-helper: PROBLEM https://yukicoder.me/problems/no/451

def main() -> None:
    n = int(input())
    b = [int(input()) for _ in range(n)]
    i, mid = 0, 0
    a = [1] * (n + 1)
    while i < n:
        if i % 2:
            a[i + 1] = a[i] - b[i]
        else:
            a[i + 1] = a[i] + b[i]
        
        if a[i + 1] <= 0 or a[i + 1] > 10**18:
            a[0] += 1 - a[i + 1]
            i = -1
            mid += 1
        if mid == 10:
            exit(print(-1))
        i += 1
    
    if a[0] <= 0:
        exit(print(-1))
    
    print(n + 1)
    for i in range(n + 1):
        print(a[i])


if __name__ == "__main__":
    main()
0