Advertisement
HuanMatus

Untitled

Dec 16th, 2021
1,086
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. N, M = input().split()
  2. N, M = int(N), int(M)
  3. bills = []
  4. for i in range(N):
  5.     bills.append(int(input()))
  6. bills.sort(reverse=True)  # Сначала дорогие чеки
  7. m_max_bills = bills[:M]  # первые M штук из них
  8. S1 = sum(m_max_bills)  # первый ответ
  9. unique_bills = list(set(m_max_bills))
  10. unique_bills.sort()  # Сорт. по возр. чтобы убрать макс. кол-во чеков
  11. money_left_in_checkout = S1  # Сколько остается денег после возврата чеков
  12. for price in unique_bills:
  13.     if money_left_in_checkout - price > 0.9 * S1:  # Убираем чек и если еще > 90% от S1
  14.         money_left_in_checkout -= price  # то действительно его убираем
  15.     else:
  16.         S2 = money_left_in_checkout  # уже не можем убирать тк станет < 90% от S1
  17.         print(S1, S2)  # 428860 389101
  18.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement