package leetcode;

/**
 * https://leetcode.com/problems/grumpy-bookstore-owner/
 */
public class Problem1052 {
    public int maxSatisfied(int[] customers, int[] grumpy, int X) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1052 prob = new Problem1052();
        System.out.println(prob.maxSatisfied(new int[]{1, 0, 1, 2, 1, 1, 7, 5}, new int[]{0, 1, 0, 1, 0, 1, 0, 1}, 3)); // 16
    }
}

@@ -184,82 +184,232 @@
     
-// TODO%0A        return 0;
+int satisfiedSum = 0;%0A        for (int i = 0; i %3C customers.length; i++) %7B
 %0A    
-%7D%0A%0A
+   
     
-public
  s
-t
 ati
-c void main(String%5B%5D args
+sfiedSum += customers%5Bi%5D;%0A        %7D%0A        int%5B%5D grumpySums = new int%5Bgrumpy.length%5D;%0A        for (int i = 0; i %3C grumpy.length; i++
 ) %7B%0A
@@ -420,171 +420,866 @@
     
+ 
-Problem1052 prob = new Problem1052();%0A        System.out.println(prob.maxSatisfied(new int%5B%5D%7B1, 0, 1, 2, 1, 1, 7, 5%7D, new int%5B%5D%7B0, 1, 0, 1, 0, 1, 0, 1%7D, 3)); // 16
+   if (i == 0) %7B%0A                if (grumpy%5Bi%5D == 1) %7B%0A                    grumpySums%5Bi%5D = customers%5Bi%5D;%0A                %7D%0A            %7D else %7B%0A                if (grumpy%5Bi%5D == 1) %7B%0A                    grumpySums%5Bi%5D = grumpySums%5Bi - 1%5D + customers%5Bi%5D;%0A                %7D else %7B%0A                    grumpySums%5Bi%5D = grumpySums%5Bi - 1%5D;%0A                %7D%0A            %7D%0A        %7D%0A        int grumpySum = grumpySums%5BgrumpySums.length - 1%5D;%0A        int answer = satisfiedSum - grumpySum;%0A        for (int i = X - 1; i %3C grumpySums.length; i++) %7B%0A            int val = 0;%0A            if (i - X %3C 0) %7B%0A                val = (satisfiedSum - grumpySum) + grumpySums%5Bi%5D;%0A            %7D else %7B%0A                val = (satisfiedSum - grumpySum) + (grumpySums%5Bi%5D - grumpySums%5Bi - X%5D);%0A            %7D%0A            answer = Math.max(answer, val);%0A        %7D%0A        return answer;
 %0A   

Solve problem 1052