Submission #464673

#TimeUsernameProblemLanguageResultExecution timeMemory
464673ahmedfouadnewCipele (COCI18_cipele)C++17
90 / 90
377 ms2368 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back const int mod=1e9+7; int a[100001],b[100001]; int n,m; bool ok(int x) { int cur=-1; int cnt=0; for(int i=0;i<n;i++) { int l=lower_bound(b,b+m,a[i]-x)-b; int r=upper_bound(b,b+m,a[i]+x)-b-1; if(max(cur+1,l)<=r) { cur=max(cur+1,l); cnt++; } } return (cnt>=m); } int bs() { int s=0,e=1e10; while(s<e) { int mid=s+(e-s)/2; if(ok(mid)) { e=mid; } else { s=mid+1; } } return s; } signed main() { cin>>n>>m; for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<m;i++) { cin>>b[i]; } if(n<m) { for(int i=0;i<m;i++) { swap(a[i],b[i]); } swap(n,m); } sort(a,a+n); sort(b,b+m); cout<<bs()<<endl; return 0; }
#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...