Участник:Turk0v/Reducing Dishes

Материал из DISCOPAL
Перейти к: навигация, поиск
class Solution:
    def maxSatisfaction(self, satisfaction: List[int]) -> int:
        if max(satisfaction) < 0: 
            return 0
        else:
            satisfaction.sort()
            all_val = len(satisfaction)
            res = sum(satisfaction[i] * (i + 1) for i in range(all_val))
            tmp_val = sum(satisfaction)
            i = 0
            while res - tmp_val > res:
                res -= tmp_val
                tmp_val -= satisfaction[i]
                i += 1
            return res