#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 |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |