結果
問題 |
No.451 575
|
ユーザー |
![]() |
提出日時 | 2021-03-21 09:20:54 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 283 ms / 2,000 ms |
コード長 | 586 bytes |
コンパイル時間 | 245 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 29,568 KB |
最終ジャッジ日時 | 2024-11-22 00:02:17 |
合計ジャッジ時間 | 6,441 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) U = 10 ** 18 N = int(input()) B = [int(input()) for _ in range(N)] amin = 1 amax = U for i, b in enumerate(B, 1): if i % 2 == 1: x = max(1, b - amax) y = b - amin else: x = max(1, amin - b) y = amax - b if x > y: print(-1) exit() amin = x amax = y ans = [amin] for i, b in reversed(list(enumerate(B, 1))): if i % 2 == 1: ans.append(b - ans[-1]) else: ans.append(b + ans[-1]) print(N+1) print(*ans[::-1], sep="\n")