Advertisement
mbstanchev

afaf

Feb 18th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. from collections import deque
  2.  
  3. sequence_textile = deque([int(x) for x in input().split()])
  4. sequence_medicaments = [int(x) for x in input().split()]
  5.  
  6. aptechka = {}
  7.  
  8. while sequence_textile and sequence_medicaments:
  9. current_textil = sequence_textile.popleft()
  10. current_medicament = sequence_medicaments.pop()
  11. result = current_medicament + current_textil
  12.  
  13. if result == 30:
  14. if "Patch" not in aptechka.keys():
  15. aptechka["Patch"] = 0
  16. aptechka["Patch"] += 1
  17.  
  18. elif result == 40:
  19. if "Bandage" not in aptechka.keys():
  20. aptechka["Bandage"] = 0
  21. aptechka["Bandage"] += 1
  22.  
  23. elif result >= 100:
  24. if "MedKit" not in aptechka.keys():
  25. aptechka["MedKit"] = 0
  26. aptechka["MedKit"] += 1
  27.  
  28. if result > 100:
  29. if sequence_medicaments:
  30. leftover = result - 100
  31. el = sequence_medicaments.pop()
  32. el = el + leftover
  33. sequence_medicaments.append(el)
  34. # sequence_medicaments[-1] += leftover
  35. else:
  36. sequence_medicaments.append(current_medicament + 10)
  37.  
  38. aptechka = sorted(aptechka.items(), key=lambda x: (-x[1], x[0]))
  39. sequence_medicaments = sorted(sequence_medicaments, reverse=True)
  40. # sequence_textile = sorted(sequence_textile, reverse=True)
  41.  
  42.  
  43. if not sequence_textile and sequence_medicaments:
  44. print("Textiles are empty.")
  45.  
  46.  
  47. elif not sequence_medicaments and sequence_textile:
  48. print("Medicaments are empty.")
  49.  
  50. if not sequence_textile and not sequence_medicaments:
  51. print("Textiles and medicaments are both empty.")
  52.  
  53. if aptechka:
  54. for item, value in aptechka:
  55. print(f'{item} - {value}')
  56.  
  57. if sequence_textile:
  58. print(f"Textiles left: {', '.join(str(x) for x in sequence_textile)}")
  59.  
  60. if sequence_medicaments:
  61. print(f"Medicaments left: {', '.join(str(x) for x in sequence_medicaments)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement