結果

問題 No.451 575
ユーザー mkawa2mkawa2
提出日時 2020-04-25 21:36:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,814 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-04-25 10:37:34
合計ジャッジ時間 6,929 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,752 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 33 ms
10,752 KB
testcase_04 WA -
testcase_05 AC 39 ms
11,264 KB
testcase_06 AC 50 ms
12,544 KB
testcase_07 AC 126 ms
20,352 KB
testcase_08 AC 34 ms
10,752 KB
testcase_09 AC 35 ms
10,880 KB
testcase_10 AC 78 ms
12,928 KB
testcase_11 AC 167 ms
17,024 KB
testcase_12 AC 210 ms
18,816 KB
testcase_13 AC 207 ms
18,816 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 119 ms
18,688 KB
testcase_19 WA -
testcase_20 AC 40 ms
11,264 KB
testcase_21 AC 34 ms
10,880 KB
testcase_22 AC 32 ms
10,752 KB
testcase_23 AC 212 ms
19,456 KB
testcase_24 AC 133 ms
14,720 KB
testcase_25 AC 33 ms
10,752 KB
testcase_26 AC 32 ms
10,752 KB
testcase_27 AC 33 ms
10,752 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 31 ms
10,752 KB
testcase_32 AC 62 ms
13,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    inf=float("inf")
    n=II()
    bb=[II() for _ in range(n)]
    aa=[0]
    # 仮にaの初項を0としてシミュレーションする
    for i,b in enumerate(bb):
        if i%2:aa.append(-b+aa[-1])
        else:aa.append(b-aa[-1])
    # print(aa)
    # 0-indexedで考える
    # ここから答えの数列を作るには、初項をa0とすると
    # i%4==0,3のaa[i]にはa0を足す
    # i%4==1,2のaa[i]には-a0を足すとできる
    # このとき、各項が1<=aa[i]<=10**18となるようにa0を決める
    # インデックスのmod4が0,3の項の最大値と1,2の項の最小値を求める
    max03=-inf
    min12=inf
    for i,a in enumerate(aa):
        if i%4==0 or i%4==3:
            if a>max03:max03=a
        else:
            if a<min12:min12=a
    # a0を求める
    a0=min(10**18-max03,min12-1)
    # a0が1以上でないと失敗
    if a0<1:
        print(-1)
        exit()
    # 前述の方法で復元する
    print(n+1)
    for i,a in enumerate(aa):
        if i%4==0 or i%4==3:
            print(a+a0)
        else:
            print(a-a0)

main()
0