Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main ()
- {
- int N=9, S=150, K=3, aux, c=0;
- cin>>N>>S>>K;
- vector <int> precios (N+1,0);
- for (int i=1; i<=N; i++)
- {
- cin>>aux;
- precios[i]=aux;
- }
- for (int i=1; i<=N; i++)
- precios[i]=precios[i]+precios[i-1];
- for (int i=K; i<=N; i++)
- if (precios[i]-precios[i-K]<=S)
- c++;
- cout<<c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement