# 1176. Diet Plan Performance

A dieter consumes calories[i] calories on the i-th day. For every consecutive sequence of k days, they look at T, the total calories consumed during that sequence of k days:

If T < lower, they performed poorly on their diet and lose 1 point; If T > upper, they performed well on their diet and gain 1 point; Otherwise, they performed normally and there is no change in points. Return the total number of points the dieter has after all calories.length days.

Note that: The total points could be negative.

`Example 1:​Input: calories = [1,2,3,4,5], k = 1, lower = 3, upper = 3Output: 0Explaination: calories, calories < lower and calories, calories > upper, total points = 0.Example 2:​Input: calories = [3,2], k = 2, lower = 0, upper = 1Output: 1Explaination: calories + calories > upper, total points = 1.Example 3:​Input: calories = [6,5,0,0], k = 2, lower = 1, upper = 5Output: 0Explaination: calories + calories > upper, lower <= calories + calories <= upper, calories + calories < lower, total points = 0.​​Constraints:​1 <= k <= calories.length <= 10^50 <= calories[i] <= 200000 <= lower <= upper`

`class Solution {public:    int dietPlanPerformance(vector<int>& calories, int k, int lower, int upper) {        int startSum=0;        int points=0;        for( int i=0;i<k;i++)            startSum += calories[i];        if(startSum>upper)                ++points;        else if(startSum < lower)                --points;        for(int i=k; i<calories.size();i++)        {            startSum = startSum - calories[i-k]+calories[i];            if(startSum>upper)                ++points;            else if(startSum < lower)                --points;​        }        return points;    }};`