# ZCO Wormholes (C++) HELP NEEDED

Hey, so whenever I execute my code I end up with 0 as an output. This is the link for the problem that I am trying to solve. I went about writing the code in several loops.
CodeChef: Practical coding for everyone

n x y are the 3 starting numbers. The next few lines create vectors which store the input.
I then introduced a for loop to run through each contest timings and find the best/shortest times for each contest. Inside that loop, I have 2 other loops to find the optimal times before the contest and after the contest. And at the end of the loop, I stored the minimum value in btotal and provided that as output. But I canâ€™t seem to get the code to work.

The code is as follows :

``````enter code here
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

int main()

{

ll n,x,y;
ll btotal;
cin>>n;
cin>>x;
cin>>y;

vector<ll> sequence;
sequence.reserve(2*n);
copy_n(istream_iterator<ll>(cin),2*n, back_inserter(sequence));

vector<ll> vin;
vin.reserve(x);
copy_n(istream_iterator<ll>(cin),x, back_inserter(vin));

vector<ll> win;
win.reserve(y);
copy_n(istream_iterator<ll>(cin),y, back_inserter(win));

sort(win.begin(),win.end());
sort(vin.begin(),vin.end());

//to find smallest time for one event:
for (ll k=0;k<n;k++)
{

ll bestl,bestr=100000;

for(ll l=0;l<x;l++)
{

if(sequence[2*k]>vin[l])
{
ll bestl = sequence[2*k]-vin[l];
}
else if(sequence[2*k]== vin[l])
{
ll bestl = 0;
break;
}
else
{
break;
}

}
for(ll m=0;m<y;m++){

if(sequence[(2*k)+1]<win[m])
{
ll bestr = win[m]-sequence[(2*k)+1];

}
else if(sequence[(2*k)+1]== win[m])
{
ll bestr = 0;
break;
}
else
{
break;
}

}

ll total = sequence[(2*k)+1]-sequence[(2*k)]+bestl+bestr+1;
ll btotal = min(total,btotal);
if(k==n-1)
{
cout<<btotal;
}
else{
continue;
}

}

}
``````