why m i getting wrong ans for subtask 2 ?
problem : wormholes
#include <iostream>
#include<climits>
#include<algorithm>
using namespace std;
int main() {
int n , x, y ;
cin>>n>>x>>y;
pair<int ,int> a[n];
for(int i=0;i<n;i++)
{
cin>>a[i].first>>a[i].second;
}
int v[x];
for(int i =0;i<x;i++)
{cin>>v[i];}
sort(v,v+x);
int w[y];
for(int i =0;i<y;i++)
{ cin>>w[i];}
sort(w,w+y);
int d,md=INT_MAX;
for(int i=0;i<n;i++)
{ auto l1= lower_bound(v, v+x, a[i].first);
int g = (l1-v);
auto l2= lower_bound(w, w+y, a[i].second);
int h = (l2-w);
d= w[h]-v[g-1]+1;
//cout<<d<<" ";
if(d>=0)
{ md=min(md,d);}
}
cout<<md<<endl;
// your code goes here
return 0;
}