Submission #1022836

# Submission time Handle Problem Language Result Execution time Memory
1022836 2024-07-14T06:02:46 Z spensa Labels (NOI20_labels) C++17
0 / 100
25 ms 4608 KB
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i=(signed)(a); i<=(signed)(b); i++)
#define F0R(i, a) for(int i=(signed)(0); i<(signed)(a); i++)

const int MXN = 3e5 + 10;
int diff[MXN] = {0};
int ps[MXN] = {0};

int main(){
    //faster io
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin>>N;

    FOR(i, 2, N){
        cin>>diff[i];
    }
    ps[1] = 1;
    int mx = 1;
    int mn = 1;
    FOR(i, 2, N){
        ps[i] = ps[i-1] + diff[i];
        mx = max(mx, ps[i]);
        mn = min(mn, ps[i]);
    }

    if(mn<1){
        ps[1] += 1-mn;
    }
    FOR(i, 2, N){
        ps[i] = ps[i-1] + diff[i];
        mx = max(mx, ps[i]);
        mn = min(mn, ps[i]);
    }

    if(mx==N){
        FOR(i, 1, N) cout<<ps[i]<<" ";
        cout<<"\n";
    }
    else{
        cout<<"-1\n";
    }


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 4608 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 12 ms 2652 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -