Advertisement
AlenAntonelli

Macetas (06/05/2017)

May 6th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main ()
  5. {
  6. int N=9, S=150, K=3, aux, c=0;
  7. cin>>N>>S>>K;
  8. vector <int> precios (N+1,0);
  9. for (int i=1; i<=N; i++)
  10. {
  11. cin>>aux;
  12. precios[i]=aux;
  13. }
  14. for (int i=1; i<=N; i++)
  15. precios[i]=precios[i]+precios[i-1];
  16. for (int i=K; i<=N; i++)
  17. if (precios[i]-precios[i-K]<=S)
  18. c++;
  19. cout<<c;
  20.  
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement