Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int main()
- {
- int n,v[200001];
- long long val;
- ifstream f("secvmaxval.in");
- f>>n>>val;
- for(int i=1;i<=n;++i)
- f>>v[i];
- f.close();
- long long S=0;
- int i=1,Lmax=0;
- for(int j=1;j<=n;++j)
- {
- S+= v[j];
- while(S>val)
- S-=v[i++];
- if(j-i+1>Lmax)
- Lmax=j-i+1;
- }
- ofstream g("secvmaxval.out");
- g<<Lmax;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement