結果
問題 |
No.451 575
|
ユーザー |
![]() |
提出日時 | 2016-12-02 18:58:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 607 bytes |
コンパイル時間 | 1,664 ms |
コンパイル使用メモリ | 167,148 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-16 10:29:35 |
合計ジャッジ時間 | 5,268 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 19 WA * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; const ll inf=1LL<<60; ll a[100001],b[100000]; int main(void){ int n; cin >> n; for(int i=0;i<n;++i) cin >> b[i]; ll low=1LL,high=inf; for(int i=0;i<n;++i){ ll nlow,nhigh; if(i%2==0) nlow=max(low-b[i],1LL),nhigh=high-b[i]; else nlow=max(b[i]-high,1LL),nhigh=b[i]-low; low=nlow,high=nhigh; } if(low>high){ puts("-1"); return 0; } a[n]=low; for(int i=n-1;i>=0;--i){ if(i%2) a[i]=b[i]+a[i+1]; else a[i]=b[i]-a[i+1]; } cout << n+1 << endl; for(int i=0;i<=n;++i) cout << a[i] << endl; return 0; }