Submission #691325

#TimeUsernameProblemLanguageResultExecution timeMemory
691325saayan007Labels (NOI20_labels)C++17
47 / 100
1099 ms7352 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using vi = vector<int>;
using vl = vector<long long>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;

#define fur(i, a, b) for(ll i = a; i <= (ll)b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll)b; --i)
#define fr first 
#define sc second
#define mp make_pair
#define pb emplace_back
#define nl "\n"
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n;
    cin >> n;
    ll d[n];
    fur(i, 1, n) {
        cin >> d[i];
    }
    fur(i, 2, n)
        d[i] += d[i - 1];

    ll a[n + 1];
    ll ans[n + 1];
    bool cnt = 0;
    fur(i, 1, n) {
        bool valid = 1;
        a[1] = i;
        fur(j, 1, n - 1) {
            a[j + 1] = a[1] + d[j];
            if(a[j + 1] > n || a[j + 1] < 1)
                valid = 0;
        }
        if(cnt && valid) {
            cout << -1 << nl;
            return 0;
        } else if(valid) {
            cnt = 1;
            fur(i, 1, n)
                ans[i] = a[i];
        }
    }

    fur(i, 1, n)
        cout << ans[i] << ' ';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...