結果
問題 | No.451 575 |
ユーザー | tsutaj |
提出日時 | 2016-12-07 12:45:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 202 ms / 2,000 ms |
コード長 | 2,255 bytes |
コンパイル時間 | 786 ms |
コンパイル使用メモリ | 99,360 KB |
実行使用メモリ | 6,684 KB |
最終ジャッジ日時 | 2023-08-22 13:49:04 |
合計ジャッジ時間 | 4,673 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 3 ms
4,376 KB |
testcase_06 | AC | 9 ms
4,376 KB |
testcase_07 | AC | 66 ms
5,656 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 3 ms
4,376 KB |
testcase_10 | AC | 51 ms
4,376 KB |
testcase_11 | AC | 153 ms
5,796 KB |
testcase_12 | AC | 199 ms
6,684 KB |
testcase_13 | AC | 200 ms
6,508 KB |
testcase_14 | AC | 1 ms
4,376 KB |
testcase_15 | AC | 4 ms
4,384 KB |
testcase_16 | AC | 11 ms
4,376 KB |
testcase_17 | AC | 65 ms
5,692 KB |
testcase_18 | AC | 65 ms
5,688 KB |
testcase_19 | AC | 43 ms
4,868 KB |
testcase_20 | AC | 9 ms
4,380 KB |
testcase_21 | AC | 4 ms
4,380 KB |
testcase_22 | AC | 1 ms
4,380 KB |
testcase_23 | AC | 202 ms
6,424 KB |
testcase_24 | AC | 105 ms
5,060 KB |
testcase_25 | AC | 2 ms
4,376 KB |
testcase_26 | AC | 2 ms
4,380 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 2 ms
4,380 KB |
testcase_29 | AC | 8 ms
4,380 KB |
testcase_30 | AC | 65 ms
5,744 KB |
testcase_31 | AC | 1 ms
4,380 KB |
testcase_32 | AC | 15 ms
4,384 KB |
ソースコード
#include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <climits> #include <ctime> #include <cassert> using namespace std; #define rep(i,a,n) for(int i=a; i<n; i++) #define repq(i,a,n) for(int i=a; i<=n; i++) #define repr(i,a,n) for(int i=a; i>=n; i--) #define pb(a) push_back(a) #define fr first #define sc second #define INF 2000000000 #define int long long int #define X real() #define Y imag() #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) ) #define LE(n, m) ((n) < (m) + EPS) #define LEQ(n, m) ((n) <= (m) + EPS) #define GE(n, m) ((n) + EPS > (m)) #define GEQ(n, m) ((n) + EPS >= (m)) typedef vector<int> VI; typedef vector<VI> MAT; typedef pair<int, int> pii; typedef long long ll; typedef complex<double> P; typedef pair<P, P> L; typedef pair<P, double> C; int dy[]={0, 0, 1, -1}; int dx[]={1, -1, 0, 0}; int const MOD = 1000000007; namespace std { bool operator<(const P& a, const P& b) { return a.X != b.X ? a.X < b.X : a.Y < b.Y; } } int b[100010], l[100010], r[100010]; signed main() { int n; cin >> n; rep(i,0,n) cin >> b[i]; l[0] = 1, r[0] = (int)1e18 - 1; bool ok = true; rep(i,0,n) { if(i % 2 == 0) { l[i+1] = max((ll)1, b[i] - r[i]); r[i+1] = b[i] - l[i]; if(l[i+1] > r[i+1]) ok = false; } else { l[i+1] = max((ll)1, l[i] - b[i]); r[i+1] = r[i] - b[i]; if(l[i+1] > r[i+1]) ok = false; } } if(!ok) cout << -1 << endl; else { vector<int> ans; cout << n + 1 << endl; int t = l[n]; ans.pb(t); repr(i,n-1,0) { if(i % 2 == 1) { t = b[i] + t; ans.pb(t); } else { t = b[i] - t; ans.pb(t); } } reverse(ans.begin(), ans.end()); rep(i,0,ans.size()) cout << ans[i] << endl; } return 0; }