結果

問題 No.451 575
ユーザー titiatitia
提出日時 2023-08-02 03:19:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 604 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 25,780 KB
最終ジャッジ日時 2024-04-20 03:37:26
合計ジャッジ時間 6,487 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 25 ms
10,752 KB
testcase_04 AC 24 ms
10,880 KB
testcase_05 AC 40 ms
11,520 KB
testcase_06 AC 78 ms
13,312 KB
testcase_07 AC 296 ms
25,780 KB
testcase_08 AC 24 ms
10,880 KB
testcase_09 AC 27 ms
10,752 KB
testcase_10 AC 108 ms
13,824 KB
testcase_11 AC 284 ms
19,840 KB
testcase_12 AC 363 ms
22,528 KB
testcase_13 AC 360 ms
22,520 KB
testcase_14 AC 25 ms
10,880 KB
testcase_15 AC 34 ms
11,008 KB
testcase_16 AC 66 ms
12,800 KB
testcase_17 AC 305 ms
22,784 KB
testcase_18 AC 296 ms
22,648 KB
testcase_19 AC 201 ms
18,560 KB
testcase_20 AC 38 ms
11,264 KB
testcase_21 AC 27 ms
10,880 KB
testcase_22 RE -
testcase_23 AC 370 ms
23,168 KB
testcase_24 AC 223 ms
16,768 KB
testcase_25 AC 25 ms
10,624 KB
testcase_26 AC 25 ms
10,752 KB
testcase_27 AC 26 ms
10,624 KB
testcase_28 AC 27 ms
10,752 KB
testcase_29 AC 55 ms
12,032 KB
testcase_30 AC 295 ms
23,340 KB
testcase_31 AC 26 ms
10,624 KB
testcase_32 AC 116 ms
15,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

MINUS=[]
PLUS=[]

c=0
now=0

for i in range(n):
    if c==0 or c==1:
        if c==0:
            now=-now+B[i]
        else:
            now-=B[i]
        MINUS.append(now)
        
    else:
        if c==2:
            now=-now+B[i]
        else:
            now-=B[i]
        PLUS.append(now)
        

    c+=1
    c%=4

ANS=[max(1,-min(PLUS)+1)]
for i in range(n):
    if i%2==0:
        ANS.append(B[i]-ANS[-1])
    else:
        ANS.append(ANS[-1]-B[i])

if min(ANS)<=0:
    print(-1)
else:
    print(n+1)
    for ans in ANS:
        print(ans)
0