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;
int main()
{
int n;
cin >>n;
vector<int>d(n);
for(int i = 1;i<n;i++)
{
cin >>d[i];
}
int num = 0;
int ans = 0;
for(int i = 1;i<=n;i++)
{
bool flag = true;
long long k = i;
for(int j = 1;j<n;j++)
{
if(d[j]+k > n || d[j] + k <= 0)
{
flag = false;
break;
}
else
{
k+= d[i];
}
}
num += (flag==true);
if(flag)ans = i;
}
if(num != 1)
{
cout << -1 << '\n';
}
else
{
long long k = ans;
//cout << k << ' ';
for(int j:d)
{
k+= j;
cout << k << ' ';
}
}
}
# | 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... |