Language: C++

#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
#define ll long long
const int N=1e5+7,inf=0x3f3f3f3f;
ll a,b,q;
ll s[N],t[N],x;
int main()
{
    cin>>a>>b>>q;
    int j,k;
    for(rg int i=1;i<=a;i++)
        cin>>s[i];
    for(rg int i=1;i<=b;i++)
        cin>>t[i];
        s[0]=-1000000,s[a+1]=inf;
        t[0]=-1000000,t[b+1]=inf;
    for(rg int i=1;i<=q;i++)
    {
        int ans=0;
        cin>>x;
        for(j=1;j<=a;j++)
            if(s[j]>x)
                break;
        for(k=1;k<=b;k++)
            if(t[k]>x)
            break;
        ans=min(max(s[j],t[k])-x,x-min(s[j-1],t[k-1]));
        ans=min(ans,min(2*t[k]-s[j-1]-x,t[k]-2*s[j-1]+x));
        ans=min(ans,min(2*s[j]-t[k-1]-x,s[j]-2*t[k-1]+x));
            cout<<ans<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   13 |     for(rg int i=1;i<=a;i++)
      |                ^
a.cc:15:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |     for(rg int i=1;i<=b;i++)
      |                ^
a.cc:19:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 |     for(rg int i=1;i<=q;i++)
      |                ^
a.cc:30:16: error: no matching function for call to 'min(int&, const long long int&)'
   30 |         ans=min(ans,min(2*t[k]-s[j-1]-x,t[k]-2*s[j-1]+x));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:30:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   30 |         ans=min(ans,min(2*t[k]-s[j-1]-x,t[k]-2*s[j-1]+x));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:30:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         ans=min(ans,min(2*t[k]-s[j-1]-x,t[k]-2*s[j-1]+x));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:31:16: error: no matching function for call to 'min(int&, const long long int&)'
   31 |         ans=min(ans,min(2*s[j]-t[k-1]-x,s[j]-2*t[k-1]+x));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:31:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |         ans=min(ans,min(2*s[j]-t[k-1]-x,s[j]-2*t[k-1]+x));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:31:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |         ans=min(ans,min(2*s[j]-t[k-1]-x,s[j]-2*t[k-1]+x));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~