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:
break
print(s)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
273 ms |
3392 KB |
Output is correct |
2 |
Correct |
849 ms |
3532 KB |
Output is correct |
3 |
Execution timed out |
2064 ms |
3644 KB |
Time limit exceeded |
4 |
Execution timed out |
2045 ms |
3772 KB |
Time limit exceeded |
5 |
Execution timed out |
2064 ms |
87980 KB |
Time limit exceeded |
6 |
Execution timed out |
2061 ms |
95252 KB |
Time limit exceeded |
7 |
Execution timed out |
2050 ms |
78060 KB |
Time limit exceeded |
8 |
Execution timed out |
2062 ms |
77412 KB |
Time limit exceeded |
9 |
Execution timed out |
2070 ms |
84092 KB |
Time limit exceeded |
10 |
Execution timed out |
2064 ms |
85488 KB |
Time limit exceeded |