#include <limits.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <map>
#include <cstdio>
#include <iomanip>
#include <deque>
#include <array>
#include <queue>
#define ll long long
using namespace std;
const int N = 500020;
int n, d, k;
vector<array<int, 2>>block;
int cmp(array<int, 2>a, array<int, 2>b) {
return a[0] < b[0];
}
int skup(int x) {
array<int, 2> tmp = { x,0 };
return lower_bound(block.begin(), block.end(), tmp, cmp) - block.begin();
}
int skdn(int x) {
array<int, 2> tmp = { x,0 };
return upper_bound(block.begin(), block.end(), tmp, cmp) - block.begin() - 1;
}
int mx[N];
int dp[N];
deque<array<int, 2>>qe;
int qex, qey;
void moveto(int xx, int yy) {
for (int i = qey + 1; i <= yy; i++) {
if (qe.empty())
qe.push_back({ mx[i],i });
else {
while (!qe.empty() && qe.back()[0] < mx[i])
qe.pop_back();
if (qe.empty()) {
qe.push_back({ mx[i],i });
}
else {
if (qe.front()[0] == mx[i]) {
qe.front()[1] = i;
}
else {
qe.push_back({ mx[i],i });
}
}
}
}
for (int i = qex; i <= xx - 1; i++) {
if (qe.empty()) {
return;
}
if (mx[i] == qe.front()[0] && i == qe.front()[1]) {
qe.pop_front();
}
}
qex = max(xx, 0);
qey = max(yy, -1);
}
int solve(int r) {
qe.clear();
qex = 0, qey = -1;
memset(mx, 0, sizeof(mx));
moveto(0, 0);
int maxt = INT_MIN;
for (int i = 1; i <= n; i++) {
int xx = skup(max(block[i][0] - (d + r), -1));
int yy = skdn(min(block[i][0] - (d - r), block[i][0] - 1));
if (yy < xx) continue;
moveto(xx, yy);
mx[i] = qe.front()[0] + block[i][1];
maxt = max(mx[i], maxt);
if (maxt >= k)
return 1;
}
return 0;
}
int main() {
cin >> n >> d >> k;
block.push_back({ 0,0 });
for (int i = 1; i <= n; i++) {
int x, y;
cin >> x >> y;
block.push_back({ x,y });
}
int l = 0, r = 500001;
while (l < r) {
int mid = l + r >> 1;
if (solve(mid)) {
r = mid;
}
else {
l = mid + 1;
}
}
if (solve(r)) {
cout << r;
}
else {
cout << -1;
}
}