WORK #4
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n; cin >> n; --n; ll t; cin >> t; ll sum = 0; int ans = 0; int bl = 0, br = 0; vector<int> a(n); int l = 0, r = 0; while(r < n) { cin >> a[r]; a[r] *= 2; sum += a[r]; ++r; while(sum > t) { sum -= a[l]; ++l; } if(ans < r - l) { ans = r - l; bl = l; br = r; } } cout << bl + 1 << ' ' << br + 1 << '\n'; }