fork download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <queue>
  10. #include <stack>
  11. #include <algorithm>
  12. #include <iomanip>
  13. #define dibs reserve
  14. #define OVER9000 1234567890
  15. #define patkan 9
  16. #define tisic 47
  17. #define soclose 1e-9
  18. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  19. #define chocolate win
  20. #define ff first
  21. #define ss second
  22. #define abs(x) ((x < 0)?-(x):(x))
  23. // mylittledoge
  24. using namespace std;
  25.  
  26. int main() {
  27. cin.sync_with_stdio(0);
  28. cin.tie(0);
  29. int N,K;
  30. double q;
  31. cin >> N >> K >> q;
  32. vector<double> s(N), S(N+1,0);
  33. for(int i =0; i < N; i++) {
  34. cin >> s[i];
  35. S[i+1] =S[i]+s[i];}
  36.  
  37. int Rx =K; // obvious bound
  38. for(int R =K+1; R <= N; R++)
  39. if(S[R-K]-(S[R]-S[R-K])/q < -soclose) Rx =R;
  40.  
  41. int L =1; // first match that can't be won
  42. for(int R =Rx+1; R <= N; R++) {
  43. while(S[R-K]-(S[R]-S[R-K])/q > S[L-1]) L++;
  44. L++;
  45. while(S[R-K]-(S[R]-S[R-K])/q > S[L-1]) L++;}
  46.  
  47. cout << L-1 << "\n";
  48. return 0;}
  49.  
  50. // look at my code
  51. // my code is amazing
Success #stdin #stdout 0s 3476KB
stdin
10 3 1.01
47 1 1 1 1 1 1 1 3 1
stdout
8