#include <bits/stdc++.h>//h028
using namespace std;
int main(void){
int N, L;
int total = 0, radius = 0;
pair<int, int> B[100002];
stack<pair<int, int>> s;
cin >> N >> L;
B[0].first = 0;
B[0].second = INT_MAX;
for(int i = 1; i <= N; i++) cin >> B[i].first;
for(int i = 1; i <= N; i++) cin >> B[i].second;
B[N+1].first = L;
s.push(B[0]);
for(int i = 1; i <= N; i++){
if (B[i].first - B[i].second >= s.top().first ||
B[i].first + B[i].second <= B[i+1].first) {
total++;
radius = max(radius, B[i].second);
while (s.top().first + s.top().second <= B[i+1].first) {
total++;
radius = max(radius, s.top().second);
s.pop();
}
} else {
s.push(B[i]);
}
}
cout << total << '\n' << radius;
return 0;
}
#include <bits/stdc++.h>//f166
using namespace std;
int S[1000000];
int Dis[1000000];
int main(void) {
int n, P, L, R;
queue<int> q;
int s, sL, sR;
cin >> n >> P >> L >> R;
for (int i = 0; i < n; i++) {
cin >> S[i];
Dis[i] = -1;
}
Dis[0] = 0;
if (0 == P) {
cout << 0;
return 0;
}
q.push(0);
while (1) {
if (q.empty()) {
cout << -1;
return 0;
}
s = q.front(); q.pop();
sL = s - L;
if (sL >= 0) {
sL = S[sL];
if (0 <= sL && sL < n) {
if (Dis[sL] == -1) {
Dis[sL] = Dis[s] + 1;
if (sL == P) {
cout << Dis[sL];
return 0;
}
q.push(sL);
}
}
}
sR = s + R;
if (sR < n) {
sR = S[sR];
if (0 <= sR && sR < n) {
if (Dis[sR] == -1) {
Dis[sR] = Dis[s] + 1;
if (sR == P) {
cout << Dis[sR];
return 0;
}
q.push(sR);
}
}
}
}
}