n=int(input())
L=list(map(int,input().split()))
s=0
g1=L[0]
m=sum(L)
while m:
s+=1
g=g1
g1=0
for i in range(len(L)):
if g==L[i]:
g-=1
m-=L[i]
L[i]=0
elif g1==0:
g1=L[i]
if g<1 and g1 or g1 and g<min(L[i+1:]):
break
print(s)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
59 ms |
3384 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
90 ms |
3512 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
279 ms |
3760 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
423 ms |
3768 KB |
Execution failed because the return code was nonzero |
5 |
Execution timed out |
2045 ms |
87768 KB |
Time limit exceeded |
6 |
Execution timed out |
2060 ms |
95116 KB |
Time limit exceeded |
7 |
Execution timed out |
2053 ms |
77952 KB |
Time limit exceeded |
8 |
Execution timed out |
2066 ms |
77320 KB |
Time limit exceeded |
9 |
Execution timed out |
2048 ms |
83936 KB |
Time limit exceeded |
10 |
Execution timed out |
2044 ms |
85676 KB |
Time limit exceeded |