#include <bits/stdc++.h>
using namespace std;
#define long long long
#pragma region overloadings
template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1, T2>& pair){
os << '(' << pair.first << ", " << pair.second << ')';
return os;
}
template <typename T1, typename T2>
ostream& operator<< (ostream& os, const map<T1, T2>& map_var){
for(pair<T1, T2> i: map_var){
os << '(' << i.first << ": " << i.second << ") ";
}
return os;
}
template <typename T>
ostream& operator<< (ostream& os, const vector<T>& vec){
for(T i: vec)
os << i << ' ';
return os;
}
template <typename T1, typename T2>
istream& operator>> (istream& is, pair<T1, T2>& pair){
is >> pair.first >> pair.second;
return is;
}
template <typename T>
istream& operator>> (istream& is, vector<T>& vec){
for(int i = 0; i < vec.size(); i++)
is >> vec[i];
return is;
}
#pragma endregion
bool test_cases = false;
ifstream ifile;
ofstream ofile;
// #define cin ifile
// #define cout ofile
void solution(){
int n;
cin >> n;
vector<int> D(n-1);
cin >> D;
int pref_sum[n] = {0};
for(int i = 1; i < n; i++){
pref_sum[i] = pref_sum[i-1] + D[i-1];
}
int min_num = INT_MAX;
for(int i = 0; i < n; i++){
min_num = min(pref_sum[i], min_num);
}
int max_pref = 0;
for(int i = 0; i < n; i++){
pref_sum[i] += min_num + 1;
max_pref = max(max_pref, pref_sum[i]);
}
if(max_pref < n){
cout << -1 << '\n';
}
else{
for(int i = 0; i < n; i++){
cout << pref_sum[i] << ' ';
}
}
}
int main(){
ifile.open("circlecross.in");
ofile.open("circlecross.out");
if(test_cases){
int t;
cin >> t;
while(t--){
solution();
}
}
else{
solution();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |