This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define a first
#define b second
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
if(n == 2)
{
int d;
cin >> d;
if(d == 0)
{
cout << "-1\n";
return 0;
}
if(d == 1)
{
cout << "1 2\n";
return 0;
}
if(d == -1)
{
cout << "2 1\n";
return 0;
}
}
vector<int> diff(n-1);
for(int i = 0; i < n-1; ++i)
cin >> diff[i];
vector<int> del(n);
del[0] = 1;
for(int i = 1; i < n; ++i)
del[i] = del[i-1] + diff[i-1];
sort(del.begin(),del.end());
int mxd = del[n-1] - del[0];
if(mxd != n-1)
{
cout << "-1\n";
return 0;
}
int up = 1-del[0];
int j = 1+up;
for(int i = 0; i < n-1; ++i)
{
cout << j << " ";
j += diff[i];
}
cout << j << '\n';
return 0;
}
# | 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... |