結果
問題 | No.451 575 |
ユーザー |
![]() |
提出日時 | 2017-04-18 23:58:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 1,210 bytes |
コンパイル時間 | 1,529 ms |
コンパイル使用メモリ | 170,768 KB |
実行使用メモリ | 6,620 KB |
最終ジャッジ日時 | 2024-07-19 07:50:27 |
合計ジャッジ時間 | 4,117 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) typedef long long ll; #define INF 1LL<<60 int N; ll B[101010]; //----------------------------------------------------------------------------------- vector<ll> simulate(ll a0) { vector<ll> res; res.push_back(a0); rep(i, 0, N) { if (i % 2 == 0) res.push_back(B[i] - res[i]); else res.push_back(res[i] - B[i]); } return res; } //----------------------------------------------------------------------------------- int main() { cin >> N; rep(i, 0, N) scanf("%lld", &B[i]); vector<ll> a; a = simulate(0); /*rep(i, 0, N + 1) printf("%lld\n", a[i]); cout << endl;*/ ll L = 1, R = INF; rep(i, 0, N + 1) { if (i % 4 == 0 || i % 4 == 3) { if (a[i] < 1) { L = max(L, 1 - a[i]); } } else { if (a[i] <= 0) { printf("-1\n"); return 0; } R = min(R, a[i] - 1); } } if (R < L) { printf("-1\n"); return 0; } a = simulate(L); cout << N + 1 << endl; rep(i, 0, N + 1) printf("%lld\n", a[i]); }