#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n,p; long long k; cin >> n >> k >> p; vector a(n); vector b(n); for (int i=0;i> a[i]; } for (int i=0;i> b[i]; } sort(a.begin(),a.end()); sort(b.begin(),b.end()); int i = 0; int j = n-1; long long pcnt = 0; while (i < n && j >= 0) { if (a[i]+b[j] < p) { pcnt += j+1; i++; } else { j--; } } int l = 0; int h = p-1; int las = h; while (l <= h) { int now = (l+h)/2; i = 0; j = n-1; long long ncnt = 0; while (i < n && j >= 0) { if (a[i]+b[j] <= now) { ncnt += j+1; i++; } else { j--; } } i = 0; j = n-1; long long npcnt = 0; while (i < n && j >= 0) { if (a[i]+b[j] <= now+p) { ncnt += j+1; i++; } else { j--; } } long long cnt = npcnt-pcnt+ncnt; //cout << now << ' ' << cnt << endl; if (cnt >= k) { las = now; h = now-1; } else { l = now+1; } } cout << las << endl; }