标签:size long div mem orm set solution eof fine
1 #define _for(i,a,b) for(int i = (a);i < b;i ++) 2 #define _rep(i,a,b) for(int i = (a);i > b;i --) 3 4 class Solution 5 { 6 public: 7 int dietPlanPerformance(vector<int>& calories, int k, int lower, int upper) 8 { 9 long long sum[100003]; 10 memset(sum,0,sizeof(sum)); 11 sum[1] = calories[0]; 12 _for(i,2,calories.size()+1) 13 sum[i] = sum[i-1]+calories[i-1]; 14 15 int tol = 0; 16 _for(i,0,calories.size()-k+1) 17 { 18 if(sum[i+k]-sum[i]<lower) 19 tol --; 20 else if(sum[i+k]-sum[i]>upper) 21 tol ++; 22 } 23 return tol; 24 } 25 };
Leetcode-5174 Diet Plan Performance(健身计划评估)
标签:size long div mem orm set solution eof fine
原文地址:https://www.cnblogs.com/Asurudo/p/11442042.html