Submission #85974

#TimeUsernameProblemLanguageResultExecution timeMemory
85974theknife2001Cipele (COCI18_cipele)C++17
90 / 90
113 ms12296 KiB
#include <bits/stdc++.h> #define mid (l+r)/2 using namespace std; const int N=1e5+55; int a[N]; int b[N]; int n,m; bool ok(int x) { int j=0,i=0; if(n<m) { for(j=0,i=0;i<n;i++,j++) { while(abs(a[i]-b[j])>x&&j<m) { j++; } if(j==m) return 0; } return (i==n); } else { for(j=0,i=0;j<m;i++,j++) { while(abs(a[i]-b[j])>x&&i<n) { i++; } if(i==n) return 0; } return (j==m); } } int main() { cin>>n>>m; for(int i=0;i<n;i++) cin>>a[i]; for(int j=0;j<m;j++) cin>>b[j]; sort(a,a+n); sort(b,b+m); int l=0,r=1e9+55; while(l<r) { if(ok(mid)) r=mid; else l=mid+1; } cout<<l<<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...