結果

問題 No.451 575
ユーザー tottoripaper
提出日時 2016-12-31 21:50:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,228 bytes
コンパイル時間 1,265 ms
コンパイル使用メモリ 160,208 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-16 11:04:38
合計ジャッジ時間 6,101 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
ll A[100100], B[100100];

bool isValid(){
    for(int i=0;i<N;i+=2){
        if(A[i] <= A[i+1]){return false;}
    }
    return true;
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    if(N == 1){
        if(A[0] > 1){
            std::cout << 2 << std::endl;
            std::cout << 1 << std::endl;
            std::cout << (A[0] - 1) << std::endl;
        }else{
            std::cout << "-1" << std::endl;
        }
        return 0;
    }
    
    if(!isValid()){
        std::cout << "-1" << std::endl;
        return 0;
    }

    std::cout << (N+1) << std::endl;
    
    B[0] = 1;
    for(int i=0;i<N+1;++i){
        std::cout << B[i] << std::endl;

        if(i % 2 == 0){ // b_i = a_i + a_{i+1}
            B[i+1] = A[i] - B[i];
        }else{ // b_i = a_i - a_{i+1}
            B[i+1] = B[i] - A[i];
        }
    }
}
0