#include<bits/stdc++.h>usingnamespace std;structnode{int pos, p;}a[500005];structedge{int pos, s;booloperator<(const edge tmp)const{return s < tmp.s;}} pre;
priority_queue<edge> q, t;int n, d, k;boolcheck(int x){while(q.size()){
q.pop();}while(t.size()){
t.pop();}
pre.pos =0;
pre.s =0;
q.push(pre);for(int i =1; i <= n;++i){while(q.size()){
pre = q.top();if(a[i].pos - pre.pos > d + x){
q.pop();}elseif(a[i].pos - pre.pos <max(1, d - x)){
t.push(q.top());
q.pop();}else{break;}}if(!q.size()){while(t.size()){
q.push(t.top());
t.pop();}continue;}
pre.pos = a[i].pos;
pre.s = pre.s + a[i].p;if(pre.s >= k){returntrue;}
q.push(pre);while(t.size()){
q.push(t.top());
t.pop();}}returnfalse;}intmain(){
cin >> n >> d >> k;int l =-1, r =0, res =-1;for(int i =1; i <= n;++i){
cin >> a[i].pos >> a[i].p;
r =max(r, a[i].pos);}++r;while(l < r -1){int mid = l + r >>1;if(check(mid)){
r = mid;
res = r;}else{
l = mid;}}
cout << res <<'\n';return0;}