Submission #240656

#TimeUsernameProblemLanguageResultExecution timeMemory
240656DavidDamianCipele (COCI18_cipele)C++11
90 / 90
53 ms1272 KiB
#include <bits/stdc++.h> using namespace std; ///Binary Search The Answer int n,m; int A[100005]; int B[100005]; bool possible(int maxDiff) ///Returns whether is possible to match shoes with at most maxDiff ugliness { int j=0; for(int i=0;i<n;i++){ while(j<m && abs(A[i]-B[j]) > maxDiff) j++; if(j==m) return false; //We have no more shoes to match j++; } return true; //Shoes matched successfully } int binarySearch() ///Return the first moment when is possible { int k=-1; for(int b=1000000007;b>=1;b/=2){ while(!possible(k+b)) k+=b; } return k+1; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); 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){ swap(n,m); swap(A,B); } sort(A,A+n); sort(B,B+m); cout<<binarySearch()<<'\n'; 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...