結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 27 ms
10,624 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 43 ms
11,392 KB
testcase_06 AC 84 ms
13,440 KB
testcase_07 AC 320 ms
25,788 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 AC 30 ms
11,008 KB
testcase_10 AC 115 ms
13,824 KB
testcase_11 AC 311 ms
19,824 KB
testcase_12 AC 404 ms
22,528 KB
testcase_13 AC 383 ms
22,648 KB
testcase_14 AC 26 ms
10,752 KB
testcase_15 AC 36 ms
11,136 KB
testcase_16 AC 73 ms
12,544 KB
testcase_17 AC 328 ms
22,528 KB
testcase_18 AC 317 ms
22,652 KB
testcase_19 AC 220 ms
18,520 KB
testcase_20 AC 41 ms
11,264 KB
testcase_21 AC 30 ms
11,008 KB
testcase_22 AC 26 ms
10,752 KB
testcase_23 AC 394 ms
23,168 KB
testcase_24 AC 234 ms
16,768 KB
testcase_25 AC 26 ms
10,752 KB
testcase_26 AC 27 ms
10,752 KB
testcase_27 AC 28 ms
10,752 KB
testcase_28 AC 31 ms
10,880 KB
testcase_29 AC 59 ms
12,032 KB
testcase_30 AC 320 ms
23,340 KB
testcase_31 AC 26 ms
10,624 KB
testcase_32 AC 133 ms
15,616 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

if PLUS==[]:
    PLUS=[0]
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