#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define vn vector <ll>
using namespace std;
const int MAX_N = 1e9 + 7;
#define pii pair <ll,ll>
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define pb push_back
#define srt(vp) sort(vp.begin(), vp.end())
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n, s, k;
cin >> n >> s >> k;
k = n*k;
vn a(n+1, 0);
vn b(n+1, 0);
for (int i = 1; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
// pref1[i] = distance from module 1 to module i
// so pref1[1] = 0, pref1[2] = a[1], etc.
vn pref1(n+1, 0);
for (int i = 2; i <= n; i++) {
pref1[i] = pref1[i - 1] + a[i - 1];//made mistake here
}
vn pref2(n+1, 0);
for (int i = 1; i <= n; i++) {
pref2[i] = pref2[i - 1] + b[i];
}
ll ans = -1;
ll output = 1;
for (int i = 1; i <= n; i++) {
ll leftDist = pref1[i] - k;
auto j = lower_bound(pref1.begin(), pref1.end(), leftDist);//made mistake here
ll l = j - pref1.begin();
if (l < 1) l = 1;
ll rightDist = pref1[i] + k;
auto m = upper_bound(pref1.begin(), pref1.end(), rightDist);//made mistake here
ll r = (m - pref1.begin()) - 1;
if (r > n) r = n;
ll sum = pref2[r] - pref2[l - 1];
if (sum > ans) {
ans = sum;
output = i;
}
}
cout << 1 << endl;
cout << output << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |