编程语言
首页 > 编程语言> > python leetcode 每日打卡之1052

python leetcode 每日打卡之1052

作者:互联网

class Solution:
    def maxSatisfied(self, customers: List[int], grumpy: List[int], X: int) -> int:
        A = sum(customers)
        for i in range(len(customers)):
            if grumpy[i] == 0:
                customers[i] = 0
        res = sum(customers[:X])
        tmp = res
        for i in range(len(customers) - X):
            tmp = tmp - customers[i] + customers[i + X]
            res = max(res , tmp)
        return A + res - sum(customers)

 

标签:tmp,grumpy,customers,python,res,sum,int,打卡,leetcode
来源: https://blog.csdn.net/aaa12389zhx/article/details/114004911