제출 #1330020

#제출 시각아이디문제언어결과실행 시간메모리
1330020michael12Labels (NOI20_labels)C++20
0 / 100
25 ms4832 KiB
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define endl '\n'
#define int long long
using namespace std;
const int maxn = 1e6 + 5;
const int inf = 1e9 + 5;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 1; i < n; i++){
        cin >> a[i];
    }
    for(int i = 2; i < n; i++){
        a[i] += a[i - 1];
    }
    int mx = - inf, mn = inf;
    for(int i = 1; i < n; i++){
        mx = max(mx, a[i]);
        mn = min(mn, a[i]);
    }
    int cnt = 0, ans = 0;
    for(int i = 1; i <= n; i++){
        if(i + mx <= n && i + mn >= 1){
            cnt += 1;
            ans = i;
        }
    }
    if(cnt == 0){
        cout << "-1";
    }
    else{
        for(int i = 0; i < n; i++){
            cout << ans + a[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...