結果

問題 No.451 575
ユーザー hiro71687khiro71687k
提出日時 2023-05-21 01:36:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,423 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 199,908 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-23 10:58:50
合計ジャッジ時間 8,090 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 64 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 193 ms
4,376 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 1 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 WA -
testcase_29 AC 8 ms
4,376 KB
testcase_30 AC 64 ms
4,380 KB
testcase_31 WA -
testcase_32 AC 15 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=300000000;
ll mod=998244353;
int main(){
    ll n;
    cin >> n;
    vector<ll>b(n);
    ll d=1000000000000000000;
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    ll now=0;
    bool ok=true;
    ll pl=1,mn=d;
    if (n==1&&b[0]==1)
    {
        cout << -1 << endl;
        return 0;
    }
    for (ll i = 1; i < n; i+=2)
    {
        now*=-1;
        now+=b[i-1]-b[i];
        if ((i/2)%2==0)
        {
            if (d-now<=0||2*d<-now)
            {
                ok=false;
                break;
            }
            pl=max(pl,-d-now);
            mn=min(mn,d-now);
        }else{
            if (d-now<=0||2*d<-now)
            {
                ok=false;
                break;
            }
            pl=max(pl,now-d+1);
            mn=min(now+d-1,mn);
        }
    }
        if (!ok)
        {
            cout << -1 << endl;
            return 0;;
        }
        if (pl>mn)
        {
            cout << -1 << endl;
            return 0;
        }
        ll nn=pl;
        cout << n+1 << endl;
        cout << nn << endl;
        for (ll i = 0; i < n; i++)
        {
            if (i%2==0)
            {
                nn*=-1;
                nn+=b[i];
            }else{
                nn-=b[i];
            }
            cout << nn << endl;
        }
}
0