Submission #38019678


Source Code Expand

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define ff(i,s,f) for(ll i=s;i<f;i++)
#define fb(i,s,f) for(ll i=(s)-1;i>=f;i--)
#define ffi(i,s,f) for(ll i=s;i<=f;i++)
#define fbi(i,s,f) for(ll i=s;i>=f;i--)
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,ll) sort(a.begin(),a.end(),greater<ll>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;
typedef string str;

const ll maxn=2e5+10;

ll a[maxn];
ll b[maxn];

void solve(){
    ll n;
    cin>>n;
    ff(i,0,n) cin>>a[i];
    ll sum=0;
    ll cnt=0;
    ff(i,0,n){
        cnt+=a[i];
        sum+=a[i]*i;
    }
    ll dpref=-1;
    ll dsuf=-1;
    ll tren=0;
    ff(i,0,n){
        tren+=a[i];
        if(tren==-1) dpref=i;
    }
    tren=0;
    fb(i,n,0){
        tren+=a[i];
        if(tren==1) dsuf=i;
    }
    if(cnt==0){
        cout<<"No\n";
    }else if(dpref!=-1){
        cout<<"Yes\n";
        ll x=-sum/cnt;
        while(x*cnt+sum<0) x+=cnt/abs(cnt);
        ll dod=x*cnt+sum;
        for(ll i=0;i<n;i++){
            if(i<=dpref){
                cout<<x+i-dod<<" ";
            }else cout<<x+i<<" ";
        }
    }else if(dsuf!=-1){
        cout<<"Yes\n";
        ll x=-sum/cnt;
        while(x*cnt+sum>0) x-=cnt/abs(cnt);
        ll dod=x*cnt+sum;
        for(ll i=0;i<n;i++){
            if(i>=dsuf){
                cout<<x+i-dod<<" ";
            }else cout<<x+i<<" ";
        }
    }else{
        cout<<"No\n";
    }
}

int main(){
    ios;
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Submission Info

Submission Time
Task C - ± Increasing Sequence
User FEDIKUS
Language C++ (GCC 9.2.1)
Score 0
Code Size 1954 Byte
Status WA
Exec Time 35 ms
Memory 5136 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 3
AC × 45
WA × 31
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_1_01.txt, 02_small_1_02.txt, 02_small_1_03.txt, 02_small_1_04.txt, 02_small_1_05.txt, 02_small_1_06.txt, 02_small_1_07.txt, 02_small_1_08.txt, 02_small_1_09.txt, 02_small_1_10.txt, 02_small_1_11.txt, 02_small_1_12.txt, 02_small_1_13.txt, 02_small_1_14.txt, 03_small_2_01.txt, 03_small_2_02.txt, 03_small_2_03.txt, 03_small_2_04.txt, 03_small_2_05.txt, 03_small_2_06.txt, 03_small_2_07.txt, 03_small_2_08.txt, 03_small_2_09.txt, 03_small_2_10.txt, 04_small_zero_01.txt, 04_small_zero_02.txt, 04_small_zero_03.txt, 04_small_zero_04.txt, 05_small_bracket_01.txt, 05_small_bracket_02.txt, 05_small_bracket_03.txt, 05_small_bracket_04.txt, 06_max_rand_01.txt, 06_max_rand_02.txt, 06_max_rand_03.txt, 06_max_rand_04.txt, 06_max_rand_05.txt, 06_max_rand_06.txt, 06_max_rand_07.txt, 06_max_rand_08.txt, 06_max_rand_09.txt, 06_max_rand_10.txt, 07_max_zero_01.txt, 07_max_zero_02.txt, 07_max_zero_03.txt, 07_max_zero_04.txt, 07_max_zero_05.txt, 07_max_zero_06.txt, 07_max_zero_07.txt, 07_max_zero_08.txt, 07_max_zero_09.txt, 07_max_zero_10.txt, 08_max_bracket_01.txt, 08_max_bracket_02.txt, 08_max_bracket_03.txt, 08_max_bracket_04.txt, 08_max_bracket_05.txt, 08_max_bracket_06.txt, 08_max_bracket_07.txt, 08_max_bracket_08.txt, 08_max_bracket_09.txt, 08_max_bracket_10.txt, 09_almost_same_01.txt, 09_almost_same_02.txt, 09_almost_same_03.txt, 09_almost_same_04.txt, 09_almost_same_05.txt, 10_handmade_01.txt, 10_handmade_02.txt, 10_handmade_03.txt, 10_handmade_04.txt, 10_handmade_05.txt, 10_handmade_06.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 1 ms 3484 KiB
01_sample_02.txt AC 2 ms 3532 KiB
01_sample_03.txt AC 3 ms 3528 KiB
02_small_1_01.txt AC 3 ms 3428 KiB
02_small_1_02.txt AC 3 ms 3492 KiB
02_small_1_03.txt AC 2 ms 3500 KiB
02_small_1_04.txt AC 2 ms 3452 KiB
02_small_1_05.txt AC 3 ms 3488 KiB
02_small_1_06.txt WA 2 ms 3508 KiB
02_small_1_07.txt AC 2 ms 3496 KiB
02_small_1_08.txt AC 2 ms 3504 KiB
02_small_1_09.txt AC 3 ms 3488 KiB
02_small_1_10.txt AC 2 ms 3504 KiB
02_small_1_11.txt AC 2 ms 3504 KiB
02_small_1_12.txt AC 2 ms 3432 KiB
02_small_1_13.txt AC 2 ms 3500 KiB
02_small_1_14.txt AC 2 ms 3492 KiB
03_small_2_01.txt AC 2 ms 3492 KiB
03_small_2_02.txt AC 3 ms 3492 KiB
03_small_2_03.txt WA 2 ms 3488 KiB
03_small_2_04.txt AC 2 ms 3508 KiB
03_small_2_05.txt WA 2 ms 3496 KiB
03_small_2_06.txt AC 3 ms 3488 KiB
03_small_2_07.txt WA 2 ms 3532 KiB
03_small_2_08.txt AC 2 ms 3488 KiB
03_small_2_09.txt WA 4 ms 3496 KiB
03_small_2_10.txt AC 2 ms 3508 KiB
04_small_zero_01.txt WA 2 ms 3504 KiB
04_small_zero_02.txt WA 2 ms 3500 KiB
04_small_zero_03.txt WA 2 ms 3508 KiB
04_small_zero_04.txt AC 3 ms 3528 KiB
05_small_bracket_01.txt AC 2 ms 3492 KiB
05_small_bracket_02.txt AC 2 ms 3488 KiB
05_small_bracket_03.txt AC 3 ms 3528 KiB
05_small_bracket_04.txt AC 2 ms 3508 KiB
06_max_rand_01.txt WA 33 ms 5004 KiB
06_max_rand_02.txt WA 32 ms 5080 KiB
06_max_rand_03.txt WA 34 ms 5136 KiB
06_max_rand_04.txt WA 34 ms 5068 KiB
06_max_rand_05.txt WA 34 ms 5000 KiB
06_max_rand_06.txt WA 33 ms 5064 KiB
06_max_rand_07.txt WA 33 ms 5132 KiB
06_max_rand_08.txt WA 33 ms 5136 KiB
06_max_rand_09.txt WA 35 ms 5136 KiB
06_max_rand_10.txt WA 33 ms 5136 KiB
07_max_zero_01.txt WA 19 ms 5068 KiB
07_max_zero_02.txt WA 22 ms 5000 KiB
07_max_zero_03.txt WA 23 ms 5072 KiB
07_max_zero_04.txt WA 21 ms 5028 KiB
07_max_zero_05.txt WA 19 ms 5060 KiB
07_max_zero_06.txt WA 20 ms 5128 KiB
07_max_zero_07.txt WA 18 ms 5064 KiB
07_max_zero_08.txt WA 17 ms 5056 KiB
07_max_zero_09.txt WA 22 ms 5060 KiB
07_max_zero_10.txt WA 22 ms 5072 KiB
08_max_bracket_01.txt AC 17 ms 5064 KiB
08_max_bracket_02.txt AC 18 ms 5076 KiB
08_max_bracket_03.txt AC 17 ms 5060 KiB
08_max_bracket_04.txt AC 17 ms 5056 KiB
08_max_bracket_05.txt AC 17 ms 5132 KiB
08_max_bracket_06.txt AC 17 ms 5060 KiB
08_max_bracket_07.txt AC 23 ms 5064 KiB
08_max_bracket_08.txt AC 17 ms 5072 KiB
08_max_bracket_09.txt AC 17 ms 5068 KiB
08_max_bracket_10.txt AC 18 ms 5056 KiB
09_almost_same_01.txt WA 34 ms 5072 KiB
09_almost_same_02.txt AC 30 ms 5060 KiB
09_almost_same_03.txt WA 35 ms 5028 KiB
09_almost_same_04.txt AC 32 ms 5100 KiB
09_almost_same_05.txt AC 31 ms 5104 KiB
10_handmade_01.txt AC 33 ms 5132 KiB
10_handmade_02.txt WA 34 ms 5104 KiB
10_handmade_03.txt AC 16 ms 5076 KiB
10_handmade_04.txt AC 22 ms 5024 KiB
10_handmade_05.txt AC 16 ms 5096 KiB
10_handmade_06.txt AC 17 ms 5060 KiB