# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1122778 | Choco | Labels (NOI20_labels) | C++20 | 0 ms | 0 KiB |
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define INF 1e9
#define fori(x,y,z) for(ll x=y;x<=z;x++)
#define pb push_back
int main(){
// The following line disables syncing between cin/scanf and cout/printf.
// It makes input faster, but you must not use functions from <cstdio> (e.g. scanf/printf) directly.
// This line must be executed before any use of cin/cout.
ios_base::sync_with_stdio(false);
// Your code goes here ...
// (You can now read input and write output normally using cin/cout.)
ll n;
cin>>n;
vector<ll>d(n+10);
ll sum=0;
ll minimum=INF,maximum=-INF;
bool have=0;
fori(i,1,n-1){
ll a;
cin>>a;
sum+=a;
d[i]=sum;
if(a==0)
have=1;
minimum=min(d[i],minimum);
maximum=max(maximum,d[i]);
}
vector<ll>ans;
if(have==1){
cout<<-1;
return;
}
ll s=n-maximum;
ans.pb(s);
fori(i,1,n-1){
//cout<<d[i]<<" ";
ans.pb(d[i]+s);
}
fori(i,0,n-1)
cout<<ans[i]<<' ';
}