This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n, l, ans = 0;
cin >> n >> l;
int a[n+10], b[n+10], x[n+10];
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
a[0] = 0;
for(int i = 1; i <= n; i++) cin >> x[i];
int gg = n;
for(int i = 1; i <= n; ++i) {
b[gg] = fabs(l - a[i]);
gg--;
}
b[n+1] = 0;
b[0] = 0;
int dex = 0;
for(int i = 0; i <= n; i++) {
int cnt = 0;
dex += b[i];
if(dex <= x[n - (i - 1)]) cnt++;
int gs = dex * 2;
for(int j = 1; j <= n - i; j++) {
gs += fabs(a[j-1] - a[j]);
cnt += (gs <= x[i]);
}
ans = max(ans, cnt);
}
dex = 0;
for(int i = 0; i <= n; i++) {
int cnt = 0;
dex += a[i];
if(dex <= x[i]) cnt++;
int gs = dex * 2;
for(int j = n; j >= 1 + i; j--) {
gs += fabs(b[j + 1] - b[j]);
cnt += (gs <= x[j]);
ans = max(ans, cnt);
}
}
cout << ans << endl;
}
# | 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... |