結果

問題 No.451 575
ユーザー KKT89
提出日時 2020-07-13 17:44:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,127 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 108,468 KB
最終ジャッジ日時 2025-01-11 20:17:34
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> b(n);
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    ll l=1LL,r=1LL<<60;
    for(int i=0;i<n;i++){
        ll nl,nr;
        if(i%2==0){
            nl=max(1LL,b[i]-r);
            nr=min(1LL<<60,b[i]-l);
        }
        else{
            nl=max(1LL,l-b[i]);
            nr=min(1LL<<60,r-b[i]);
        }
        l=nl,r=nr;
    }
    if(l>r){
        printf("-1\n");
    }
    else{
        vector<ll> a(n+1);
        a[n]=l;
        for(int i=n-1;i>=0;i--){
            if(i%2){
                a[i]=b[i]+a[i+1];
            }
            else{
                a[i]=b[i]-a[i+1];
            }
        }
        printf("%d\n",n+1);
        for(int i=0;i<=n;i++){
            printf("%lld\n",a[i]);
        }
    }
}
0