Submission #464662

#TimeUsernameProblemLanguageResultExecution timeMemory
464662Sarah_MokhtarCipele (COCI18_cipele)C++14
54 / 90
156 ms2600 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define read freopen("in.txt","r",stdin);freopen("out.txt","w",stdout); #define LESSGO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); const ll N=1e6+10,M=505,OO=1e16,mod=1e9+7; int n,m; vector<ll>a,b; bool ok(ll bound){ int l=0; for(int i=0;i<n;++i){ int idx=lower_bound(b.begin()+l,b.end(),a[i]-bound)-b.begin(); if(b[idx]>a[i]||idx==m){ if(b[idx]-a[i]>bound) return 0; } l=idx+1; } return 1; } ll bs(){ ll low=0,high=1e12,med; while(low<high){ med=(low+high)>>1; if(ok(med)) high=med; else low=med+1; } return low; } int main(){ cin>>n>>m; for(int i=0;i<n;++i){ ll x; cin>>x; a.push_back(x); } for(int i=0;i<m;++i){ ll x; cin>>x; b.push_back(x); } if(n>m){ swap(a,b); swap(n,m); } sort(a.begin(),a.end()); sort(b.begin(),b.end()); cout<<bs()<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...