結果

問題 No.451 575
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-04-18 18:06:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,212 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 168,340 KB
実行使用メモリ 6,384 KB
最終ジャッジ日時 2023-09-26 13:23:46
合計ジャッジ時間 6,519 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,388 KB
testcase_06 AC 5 ms
4,384 KB
testcase_07 AC 22 ms
4,960 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 35 ms
6,160 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 22 ms
4,952 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,384 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 WA -
testcase_29 AC 3 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(1);

    /*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] <= 0) {
                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]);
}
0