TOPIC

Time limit exceeded

Douglas Constant asked 3 years ago

def ordenar(): menor = lista[0] for i in range(len(lista)): for k in range(i,len(lista)): if lista[k]<menor: lista[i],lista[k] = lista[k],lista[i] menor = lista[i] return lista n = int(input()) lista = [None]*n for p in range(n): lista[p] = int(input()) r = ordenar() par = [] impar = [] for m in range(len(lista)): if lista[m]%2==0: par.append(lista[m]) elif lista[m]%2==1: impar.append(lista[m]) maior = impar[0] for i in range(len(impar)): for k in range(i,len(impar)): if impar[k]>maior: impar[i],impar[k] = impar[k],impar[i] maior = impar[i] for n in range(len(par)): print(par[n]) for o in range(len(impar)): print(impar[o])

This topic was solved and cannot recieve new replies.