結果

問題 No.451 575
ユーザー ryusukeryusuke
提出日時 2023-07-09 19:04:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 16,152 KB
最終ジャッジ日時 2023-09-30 22:40:13
合計ジャッジ時間 6,154 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,760 KB
testcase_01 AC 15 ms
7,840 KB
testcase_02 AC 16 ms
8,120 KB
testcase_03 AC 14 ms
7,820 KB
testcase_04 AC 15 ms
8,080 KB
testcase_05 AC 26 ms
8,568 KB
testcase_06 AC 47 ms
9,096 KB
testcase_07 AC 195 ms
12,936 KB
testcase_08 AC 16 ms
7,944 KB
testcase_09 AC 17 ms
8,244 KB
testcase_10 AC 85 ms
10,160 KB
testcase_11 AC 299 ms
14,268 KB
testcase_12 AC 379 ms
16,140 KB
testcase_13 AC 291 ms
16,036 KB
testcase_14 AC 16 ms
8,084 KB
testcase_15 AC 23 ms
8,364 KB
testcase_16 AC 56 ms
9,000 KB
testcase_17 AC 294 ms
15,992 KB
testcase_18 AC 190 ms
12,904 KB
testcase_19 AC 209 ms
12,260 KB
testcase_20 AC 26 ms
8,636 KB
testcase_21 AC 19 ms
8,368 KB
testcase_22 AC 14 ms
7,820 KB
testcase_23 AC 292 ms
16,152 KB
testcase_24 AC 201 ms
11,960 KB
testcase_25 AC 16 ms
7,836 KB
testcase_26 AC 16 ms
8,124 KB
testcase_27 AC 16 ms
8,100 KB
testcase_28 AC 21 ms
8,236 KB
testcase_29 AC 40 ms
8,988 KB
testcase_30 AC 317 ms
16,020 KB
testcase_31 AC 16 ms
8,220 KB
testcase_32 AC 76 ms
9,684 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] = b[i] - a[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