Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <queue>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- int main() {
- ios_base::sync_with_stdio(false);
- int n, m;
- cin >> n >> m;
- vector<int> v(n);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- }
- int R = 0;
- int sum = 0;
- int res = 0;
- for(int L = 0; L < n; L++) {
- while(R < n and sum + v[R] <= m) {
- sum += v[R];
- R++;
- }
- res = max(res, R - L);
- sum -= v[L];
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement