Last active
April 25, 2018 16:47
-
-
Save rodrigoamaral/f974c975a1b08c7820559aa0ab8eccf4 to your computer and use it in GitHub Desktop.
Problema: Tacos de bilhar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Tacos de bilhar | |
| Fonte: https://olimpiada.ic.unicamp.br/pratique/p1/2016/f1/tacos-bilhar/ | |
| """ | |
| c = int(input()) | |
| consultas = [int(n) for n in input().split()] | |
| if (c == len(consultas)): | |
| estoque = {} | |
| tacos_fabricados = 0 | |
| for taco in consultas: | |
| qtd = estoque.setdefault(taco, 0) | |
| if (qtd == 0): | |
| tacos_fabricados += 2 | |
| estoque[taco] -= 1 | |
| print(tacos_fabricados) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Tacos de bilhar | |
| Fonte: https://olimpiada.ic.unicamp.br/pratique/p1/2016/f1/tacos-bilhar/ | |
| """ | |
| class Estoque(): | |
| def __init__(self, c, consultas): | |
| self._c = c | |
| self._consultas = consultas | |
| self._estoque = {} | |
| self._tacos_fabricados = 0 | |
| self._calcular() | |
| def _calcular(self): | |
| for taco in self._consultas: | |
| qtd = self._estoque.setdefault(taco, 0) | |
| if (qtd == 0): | |
| self._tacos_fabricados += 2 | |
| self._estoque[taco] -= 1 | |
| @property | |
| def tacos_fabricados(self): | |
| return self._tacos_fabricados | |
| c = int(input()) | |
| consultas = [int(n) for n in input().split()] | |
| estoque = Estoque(c, consultas) | |
| print(estoque.tacos_fabricados) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment