結果
問題 | No.451 575 |
ユーザー |
![]() |
提出日時 | 2016-12-02 08:56:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 189 ms / 2,000 ms |
コード長 | 875 bytes |
コンパイル時間 | 652 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 10:48:05 |
合計ジャッジ時間 | 3,906 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 |
ソースコード
#include<iostream> #include<vector> #include<string> #include<cstring> #include<algorithm> #include<map> #include<set> #include<cmath> #include<cassert> #include<queue> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vector<int> vi; const ll INF = 1000000000ll * 1000000000ll; ll B[100010]; int N; int main() { cin >> N; for (int i = 0; i < N; i++) cin >> B[i]; ll low = 1, high = INF; ll now = 0; for (int i = 0; i < N; i++) { if (i%2 == 0) now = B[i]-now; else now = now-B[i]; if ((i/2)%2 == 0) high = min(high, now-1); else low = max(low, -now+1); } if (low > high) cout << -1 << endl; else { cout << N+1 << endl; cout << low << endl; ll now = low; for (int i = 0; i < N; i++) { if (i%2 == 0) now = B[i]-now; else now = now-B[i]; cout << now << endl; } } return 0; }