BbJLeB

04. Cinema Voucher

May 15th, 2019
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. # 04. Cinema Voucher
  2. voucher = int(input())
  3. price = 0
  4. ticketPcs = 0
  5. other_product_pcs = 0
  6. product = input()
  7.  
  8.  
  9. while product != "End":
  10.     if len(product) > 8:
  11.         price = ord(product[0]) + ord(product[1])
  12.         if voucher >= price:
  13.             voucher = voucher - price
  14.             ticketPcs += 1
  15.         else:
  16.             break
  17.  
  18.     else:
  19.         price = ord(product[0])
  20.         if voucher >= price:
  21.             voucher = voucher - price
  22.             other_product_pcs += 1
  23.         else:
  24.             break
  25.     product = input()
  26.  
  27. print(ticketPcs)
  28. print(other_product_pcs)
Advertisement
Add Comment
Please, Sign In to add comment