結果
問題 |
No.451 575
|
ユーザー |
![]() |
提出日時 | 2016-12-02 18:59:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 600 bytes |
コンパイル時間 | 1,782 ms |
コンパイル使用メモリ | 166,692 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 11:06:14 |
合計ジャッジ時間 | 5,498 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; const ll inf=1LL<<60; ll a[100001],b[100000]; int main(){ 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) 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; }