Demo entry 6644886

Burro

   

Submitted by israelem on Oct 07, 2017 at 12:04
Language: Python 3. Code size: 771 Bytes.

if __name__ == '__main__':
    soluciones = []
    numero_casos = int(input())
    for i in range(numero_casos):
        parejas = 0
        burros, sacos = [int(x) for x in input().split(' ')]
        lista_sacos = [int(x) for x in input().split(' ')]
        while lista_sacos:
            peso = lista_sacos[0]
            ocurrencias = lista_sacos.count(peso)
            if ocurrencias % 2 == 0:
                parejas += ocurrencias // 2
            else:
                parejas += (ocurrencias - 1) // 2
            for j in range(ocurrencias):
                lista_sacos.remove(peso)
        if parejas < burros:
            soluciones.append(parejas)
        else:
            soluciones.append(burros)
    for solucion in soluciones:
        print(solucion)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).