結果
問題 | No.451 575 |
ユーザー | sekiya9311 |
提出日時 | 2016-12-05 19:22:09 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 154 ms / 2,000 ms |
コード長 | 3,418 bytes |
コンパイル時間 | 1,320 ms |
コンパイル使用メモリ | 120,320 KB |
実行使用メモリ | 4,716 KB |
最終ジャッジ日時 | 2023-08-22 13:48:12 |
合計ジャッジ時間 | 4,739 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 5 ms
4,380 KB |
testcase_07 | AC | 22 ms
4,704 KB |
testcase_08 | AC | 1 ms
4,388 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 40 ms
4,380 KB |
testcase_11 | AC | 118 ms
4,436 KB |
testcase_12 | AC | 153 ms
4,668 KB |
testcase_13 | AC | 154 ms
4,648 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 5 ms
4,384 KB |
testcase_17 | AC | 23 ms
4,660 KB |
testcase_18 | AC | 22 ms
4,584 KB |
testcase_19 | AC | 15 ms
4,380 KB |
testcase_20 | AC | 7 ms
4,380 KB |
testcase_21 | AC | 3 ms
4,376 KB |
testcase_22 | AC | 1 ms
4,376 KB |
testcase_23 | AC | 154 ms
4,716 KB |
testcase_24 | AC | 86 ms
4,376 KB |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | AC | 2 ms
4,380 KB |
testcase_27 | AC | 1 ms
4,380 KB |
testcase_28 | AC | 2 ms
4,380 KB |
testcase_29 | AC | 3 ms
4,380 KB |
testcase_30 | AC | 23 ms
4,708 KB |
testcase_31 | AC | 2 ms
4,376 KB |
testcase_32 | AC | 7 ms
4,376 KB |
ソースコード
#include <iostream> #include <string> #include <queue> #include <stack> #include <algorithm> #include <list> #include <vector> #include <complex> #include <utility> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <bitset> #include <ctime> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <cassert> #include <cstddef> #include <iomanip> #include <numeric> #include <tuple> #include <sstream> #include <fstream> #include <chrono> #include <random> using namespace std; #define REP(i, n) for (int (i) = 0; (i) < (n); (i)++) #define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++) #define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--) #define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--) #define DEBUG(C) cerr << #C << " = " << C << endl; using LL = long long; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<LL>; using VVL = vector<VL>; using VD = vector<double>; using VVD = vector<VD>; using PII = pair<int, int>; using PDD = pair<double, double>; using PLL = pair<LL, LL>; using VPII = vector<PII>; template<typename T> using VT = vector<T>; #define ALL(a) begin((a)), end((a)) #define RALL(a) rbegin((a)), rend((a)) #define SORT(a) sort(ALL((a))) #define RSORT(a) sort(RALL((a))) #define REVERSE(a) reverse(ALL((a))) #define MP make_pair #define FORE(a, b) for (auto &&a : (b)) #define FIND(s, e) ((s).find(e) != (s).end()) #define EB emplace_back const int INF = 1e9; const int MOD = INF + 7; const LL LLINF = 1e18; int N; VL a, b; /* idx % 4 == 0 || idx % 4 == 3 :++ else :-- */ int main(void) { scanf("%d", &N); b.resize(N); a.resize(N + 1); for_each(ALL(b), [](LL &e){scanf("%lld", &e);}); a[0] = 0; REP(i, N) { if ((i + 1) % 2) { a[i + 1] = b[i] - a[i]; } else { a[i + 1] = a[i] - b[i]; } } //REP(i, N + 1) cerr << a[i] << " ";cerr << endl; LL pma = 0, pmi = numeric_limits<LL>::max(); LL mma = 0, mmi = numeric_limits<LL>::max(); auto check = [](const int &idx) { return idx % 4 == 0 || idx % 4 == 3; }; REP(i, N + 1) { if (check(i)) { pmi = min(pmi, a[i]); } } pmi *= -1; if (pmi >= 0) REP(i, N + 1) { if (check(i)) { a[i] += pmi + 1; } else { a[i] -= pmi + 1; } } REP(i, N + 1) { if (!check(i)) { mmi = min(mmi, a[i]); } } mmi *= -1; if (mmi >= 0) REP(i, N + 1) { if (check(i)) { a[i] -= mmi + 1; } else { a[i] += mmi + 1; } } REP(i, N + 1) { if (!check(i)) { mma = max(mma, a[i]); } } mma = mma - LLINF; if (mma > 0) REP(i, N + 1) { if (!check(i)) { a[i] += mma; } else { a[i] -= mma; } } REP(i, N + 1) { if (check(i)) { pma = max(pma, a[i]); } } pma = pma - LLINF; if (pma > 0) REP(i, N + 1) { if (!check(i)) { a[i] -= pma; } else { a[i] += pma; } } REP(i, N + 1) if (!(1 <= a[i] && a[i] <= LLINF)) { cout << -1 << endl; return 0; } cout << N + 1 << endl; for_each(ALL(a), [](LL &e){cout << e << endl;}); }