#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
86 ms |
196448 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
88 ms |
196436 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
78 ms |
196436 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
85 ms |
196436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
737 ms |
399000 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
506 ms |
399068 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
86 ms |
196448 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
88 ms |
196436 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
78 ms |
196436 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
85 ms |
196436 KB |
Output is correct |
10 |
Runtime error |
737 ms |
399000 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |