# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320834 | ishi_10 | Labels (NOI20_labels) | C++14 | 50 ms | 7780 KiB |
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<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e5+2;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
ll a[n-1],i;
for(i=0;i<n-1;i++)
cin>>a[i];
ll s=0,f=0,pos,maxx=0;
for(i=0;i<n-1;i++)
{
s=s+a[i];
if(s>maxx)
{
maxx=s;
pos=i;
}
}
ll ans[n+1];
ll c=0;
ans[pos+1]=n;
ll j,minn=3*(1e5);
ll posj;
for(j=pos;j>=0;j--)
{
ans[j]=ans[j+1]-a[j];
if(ans[j]<minn)
{
minn=ans[j];
posj=j;
}
if(ans[j]>n || ans[j]<1)
{
c=1;
break;
}
}
for(j=pos+2;j<n;j++)
{
ans[j]=ans[j-1]+a[j-1];
if(ans[j]<minn)
{
minn=ans[j];
posj=j;
}
if(ans[j]>n || ans[j]<1)
{
c=1;
break;
}
}
if(c==0)
{
if(ans[posj]==1){
for(i=0;i<n;i++)
cout<<ans[i]<<" ";
cout<<"\n";
}
else
cout<<"-1\n";
}
else
cout<<"-1\n";
cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
Compilation message (stderr)
# | 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... |