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;
long long n,v[5010][5010],ans[5010];
int main()
{
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>v[i][0];
if(v[i][0]>0)
{
ans[i]=v[i][0];
for(int j=1;j<=n;++j)
v[i][j]=i;
continue;
}
int poz=v[i-1][-v[i][0]];
for(int j=1;j<=-v[i][0];++j)
v[i][j]=v[poz-1][j];
for(int j=-v[i][0]+1;j<=n;++j)
v[i][j]=i;
ans[i]=ans[poz-1];
}
for(int i=1;i<=n;++i)
cout<<ans[i]<<'\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... |