-
-
Save enzerr/0ad55a36323cf73af8daf98e00b2130b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
#define int long long | |
const int maxn = 1e5 + 5; | |
int v[maxn]; | |
int32_t main(){ | |
int n, D; cin >> n >> D; | |
for(int i = 0; i < n; i++) cin >> v[i]; | |
int l = 0, r = 0, val = v[0], ans = 0; | |
while(r<n){ | |
if(val<=D) ans=max(ans, r-l+1), r++, val+=v[r]; | |
else val-=v[l], l++; | |
} | |
cout << ans << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment