//```// YF YUSUF
#define Free_open(File) freopen((File".in"),"r",stdin);freopen((File".out"),"w",stdout);
#define YF ios_base::sync_with_stdio(0);cout.setf(ios::fixed);
#define YUSUF cout.precision(0);cout.tie(0);cin.tie(0);
#include <bits/stdc++.h>
using namespace std;
#ifdef YF_CHECK
bool Output=1;
// #include "g/debug.h"
//#include "g/bigint.h"
// #include "g/text.h"
#else
bool Output=0;
#define deb(x...) 42
#endif
using ll = int;
using ld = long double;
using vll = vector <ll>;
using mll = map <ll,ll>;
using pll = pair <ll,ll>;
using vpll= vector <pll>;
template<class T>T MIN(T&a,T b){a=min(a,b);return a;}
template<class T>T MAX(T&a,T b){a=max(a,b);return a;}
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("03")
#pragma optimize ("g",on)
#define revers(a) reverse(all(a))
#define all(a) a.begin(),a.end()
#define sortt(a) sort(all(a))
#define sgr v+v+1,(tl+tr)/2+1,tr
#define sgl v+v,tl,(tl+tr)/2
#define pb push_back
#define ins insert
#define S second
#define F first
ll BP(ll a,ll b,ll mod=1e9+7){
if(b==0)return 1;
ll q=BP(a,b/2,mod);
return ((q*q)%mod*(b%2?a:1ll))%mod;
}
ll dup(ll a,ll b){return (a+b-1)/b;}
ll f(ll x){return x*(x+1)/2;}
const int mod=998244353;
const ll INF=1e18+7;
const int inf=1e9+7;
const int N =2e5+7;
void YF_MAIN(ll TEST){
ll n,k;
cin>>n>>k;
vpll a(n);
for(auto &i : a){
cin>>i.F>>i.S;
i={i.F+i.S,i.S-i.F};
}
ll ans=INF;
sortt(a);
for(int i=1;i<n;i++){
MIN(ans,abs(a[i].F-a[i-1].F));
swap(a[i].F,a[i].S);
}
sortt(a);
for(int i=1;i<n;i++){
MIN(ans,abs(a[i].F-a[i-1].F));
swap(a[i].F,a[i].S);
}
cout<<ans;
}
bool TECT=0;
bool CASE=0;
bool OUTP=1;
const int FN=2;
ll FACT[FN],inv[FN],FMOD=1e9+7;
ll PER(ll n,ll k){return FACT[n] *inv[n-k]%FMOD;}
ll CNK(ll n,ll k){return PER(n,k)*inv[k ]%FMOD;}
ll lg[FN];
void BEFORE(){
return;
for(int i=2;i<FN;i++){
lg[i]=lg[i/2]+1;
}
FACT[0]=inv[0]=1;
for(int i=1;i<FN;i++){
FACT[i]=FACT[i-1]*i%FMOD;
inv[i]=BP(FACT[i],FMOD-2,FMOD);
}
}
signed main(){
if(OUTP){YF YUSUF}
// Free_open("TEST");
cout<<(Output ? "\nYF_OUTPUT:\n\n" : "");
int TEST=1;
if(TECT)
cin>>TEST;
BEFORE();
for(int T=1;T<=TEST;T++){
if(CASE)
cout<<"Case "<<T<<": ";
YF_MAIN(T);
// cout<<(T==TEST ? "" : "\n");
}
return 0;
}
//```
Compilation message (stderr)
road_construction.cpp:46:19: warning: overflow in conversion from 'double' to 'll' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
46 | const ll INF=1e18+7;
| ~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |