結果
問題 |
No.451 575
|
ユーザー |
|
提出日時 | 2016-12-02 00:47:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,063 bytes |
コンパイル時間 | 1,631 ms |
コンパイル使用メモリ | 170,572 KB |
実行使用メモリ | 5,344 KB |
最終ジャッジ日時 | 2024-12-16 08:50:13 |
合計ジャッジ時間 | 6,076 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 17 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int64_t X = 1e18; int main() { int n; cin >> n; vector<int64_t> b(n); for (int i = 0; i < n; i++) { scanf("%lld", &b[i]); if ((i + 1) / 2 % 2 == 1) { b[i] *= -1; } } for (int i = 1; i < n; i++) { b[i] += b[i - 1]; if (abs(b[i]) > 2e18) { cout << -1 << endl; return 0; } } int64_t L = 1; int64_t R = X; for (int i = 0; i < n; i++) { if (i / 2 % 2 == 0) { L = max(L, -X + b[i]); R = min(R, -1 + b[i]); } else { L = max(L, 1 + b[i]); R = min(R, X + b[i]); } } if (L > R) { cout << -1 << endl; return 0; } vector<int64_t> a; a.push_back(L); for (int i = 0; i < n; i++) { if (i / 2 % 2 == 0) { a.push_back(-L + b[i]); } else { a.push_back(L - b[i]); } } for (int i = 0; i < n; i++) { cout << a[i] << endl; } }