結果

問題 No.451 575
ユーザー tottoripapertottoripaper
提出日時 2016-12-31 21:50:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,228 bytes
コンパイル時間 1,447 ms
コンパイル使用メモリ 159,792 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-09 19:19:34
合計ジャッジ時間 7,084 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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