#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int32_t N, K, i; cin >> N >> K; vector X(N), A(N); for (i = 0; i != N; ++i) cin >> X[i]; for (i = 0; i != N; ++i) cin >> A[i]; int64_t l = X[K - 1] - A[K - 1], r = X[K - 1] + A[K - 1]; int32_t l_i = K - 2, r_i = K; while (1) { if (l_i >= 0 && X[l_i] >= l) { if (l > X[l_i] - A[l_i]) l = X[l_i] - A[l_i]; if (r < X[l_i] + A[l_i]) r = X[l_i] + A[l_i]; --l_i; continue; } if (r_i < N && X[r_i] <= r) { if (l > X[r_i] - A[r_i]) l = X[r_i] - A[r_i]; if (r < X[r_i] + A[r_i]) r = X[r_i] + A[r_i]; ++r_i; continue; } break; } cout << r_i - l_i - 1 << '\n'; return 0; }