n=int(input())
L=list(map(int,input().split()))
s=0
g1=L[0]
while L!=n*[0]:
s+=1
g=g1
g1=0
for i in range(len(L)):
if g==L[i]:
g-=1
L[i]=0
elif g1==0:
g1=L[i]
if g<1 and g1:
break
print(s)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
3904 KB |
Output is correct |
2 |
Correct |
833 ms |
3540 KB |
Output is correct |
3 |
Execution timed out |
2057 ms |
3648 KB |
Time limit exceeded |
4 |
Execution timed out |
2063 ms |
3776 KB |
Time limit exceeded |
5 |
Execution timed out |
2066 ms |
91192 KB |
Time limit exceeded |
6 |
Execution timed out |
2045 ms |
98956 KB |
Time limit exceeded |
7 |
Execution timed out |
2059 ms |
80536 KB |
Time limit exceeded |
8 |
Execution timed out |
2054 ms |
79976 KB |
Time limit exceeded |
9 |
Execution timed out |
2055 ms |
87040 KB |
Time limit exceeded |
10 |
Execution timed out |
2058 ms |
88496 KB |
Time limit exceeded |