Submission #382970

# Submission time Handle Problem Language Result Execution time Memory
382970 2021-03-28T16:04:39 Z Alexandra Baloni (COCI15_baloni) Python 3
40 / 100
2000 ms 104764 KB
n = int(input())
h = input().split()
h = list(map(int, h))
resp = 0
rotos = []

aux = []
for i in range (n):
  aux.append(h[i])

aux.sort()
if aux==h:
  print (str(n))

else:
  try:
    for i in range (len(h)):
      rotos = []
      target = min(h)
      arrow = target + 1
      o = h.index(target)
      rotos.append(o)
      resp += 1

      for j in range (o-1, -1, -1):
        if h[j] == arrow:
          arrow += 1
          rotos.append(j)

      rotos.sort(reverse=True)
      for j in range (len(rotos)):
        h.pop(rotos[j])

    print (str(resp))

  except:
    print (str(resp))
# Verdict Execution time Memory Grader output
1 Correct 59 ms 2924 KB Output is correct
2 Correct 143 ms 3052 KB Output is correct
3 Correct 455 ms 3308 KB Output is correct
4 Correct 612 ms 3564 KB Output is correct
5 Execution timed out 2081 ms 93712 KB Time limit exceeded
6 Execution timed out 2084 ms 104764 KB Time limit exceeded
7 Execution timed out 2092 ms 83224 KB Time limit exceeded
8 Execution timed out 2092 ms 82712 KB Time limit exceeded
9 Execution timed out 2097 ms 89416 KB Time limit exceeded
10 Execution timed out 2087 ms 91236 KB Time limit exceeded