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(n):
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 |
309 ms |
3416 KB |
Output is correct |
2 |
Correct |
809 ms |
3648 KB |
Output is correct |
3 |
Execution timed out |
2052 ms |
3648 KB |
Time limit exceeded |
4 |
Execution timed out |
2066 ms |
3776 KB |
Time limit exceeded |
5 |
Execution timed out |
2071 ms |
87844 KB |
Time limit exceeded |
6 |
Execution timed out |
2077 ms |
95132 KB |
Time limit exceeded |
7 |
Execution timed out |
2070 ms |
77856 KB |
Time limit exceeded |
8 |
Execution timed out |
2061 ms |
77080 KB |
Time limit exceeded |
9 |
Execution timed out |
2076 ms |
83728 KB |
Time limit exceeded |
10 |
Execution timed out |
2069 ms |
85456 KB |
Time limit exceeded |