# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
158763 | 2019-10-18T16:41:25 Z | InfiniteJest | Cipele (COCI18_cipele) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <fstream> #include <vector> #include <queue> #include <algorithm> #include <math.h> #include <map> #include <set> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); typedef long long ll; int n,m; int va[100001]; int vb[100001]; bool funz(int k){ imt indp=0; for(int i=0;i<m;i++){ bool flag=0; for(int y=indp;y<n;y++){ if(abs(va[i]-vb[i])<=k){ flag=1; indp=y+1; } } if(!flag)return 0; } return 1; } int main(){ cin>>n>>m; for(int i=0;i<n;i++)cin>>va[i]; for(int i=0;i<m;i++)cin>>vb[i]; sort(va,va+n); sort(vb,vb+m); if(n<m){ swap(va,vb); swap(n,m); } int s=0; int d=1e9+4; int minn=1e9+4; while(s<=d){ int k=(s+d)/2; if(funz(k)){ minn=min(minn,k); d=k-1; } else{ s=k+1; } } cout<<minn; }