結果

問題 No.451 575
ユーザー ytftytft
提出日時 2021-04-01 13:28:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 2,624 ms
コンパイル使用メモリ 167,008 KB
実行使用メモリ 4,920 KB
最終ジャッジ日時 2023-08-22 17:07:34
合計ジャッジ時間 6,111 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 65 ms
4,624 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 50 ms
4,380 KB
testcase_11 AC 153 ms
4,608 KB
testcase_12 AC 198 ms
4,920 KB
testcase_13 AC 193 ms
4,640 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 12 ms
4,376 KB
testcase_17 AC 66 ms
4,552 KB
testcase_18 AC 65 ms
4,564 KB
testcase_19 AC 43 ms
4,380 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 4 ms
4,384 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 196 ms
4,564 KB
testcase_24 AC 100 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 8 ms
4,380 KB
testcase_30 AC 65 ms
4,912 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 16 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<long long> b(N);
    for(int i=0;i<N;i++){
        cin>>b[i];
    }
    vector<long long> a(N+1);

    for(int i=1;i<N+1;i++){
        if(i%2){
            a[i]=b[i-1]-a[i-1];
        }else{
            a[i]=-b[i-1]+a[i-1];
        }
    }
    long long M=a[0];
    for(int i=3;i<N+1;i+=4){
        for(int j=i;(j<=i+1)&&(j<N+1);j++){
            M=min(a[j],M);
        }
    }
    a[0]=1-M;
    for(int i=1;i<N+1;i++){
        if(i%2){
            a[i]=b[i-1]-a[i-1];
        }else{
            a[i]=-b[i-1]+a[i-1];
        }
        if(a[i]<=0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<N+1<<endl;
    for(int i=0;i<N+1;i++){
        cout<<a[i]<<endl;
    }
}
0