Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <algorithm>
- #include <map>
- using namespace std;
- int main()
- {
- int n, x;
- cin >> n >> x;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- int j = 0;
- int sum = 0;
- int maks = 0;
- for(int i = 0; i < n; i++) {
- while(j < n and sum + niza[j] <= x) {
- sum += niza[j];
- j++;
- maks = max(maks, j - i);
- }
- sum -= niza[i];
- }
- cout << maks << endl;
- return 0;
- }
- /*
- 6 55
- 12 |13 14 12 11 11|
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement