Submission #1115880

#TimeUsernameProblemLanguageResultExecution timeMemory
1115880ezzzayCipele (COCI18_cipele)C++14
90 / 90
72 ms3776 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=3e5+5; int n,m; vector<int> a,b; bool check(int mid){ int j=0; int p=0; for(int i=0;i<n;i++){ if(j==m)return 0; while(j<m){ if(abs(a[i]-b[j])<=mid){ p++; j++; break; } j++; } } return p==n; } signed main(){ cin>>n>>m; a.resize(n); b.resize(m); for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<m;i++){ cin>>b[i]; } sort(a.begin(),a.end()); sort(b.begin(),b.end()); if(n>m){ swap(n,m); swap(a,b); } int hi=1e9,lo=0; while(hi>=lo){ int mid=(hi+lo)/2; bool u=check(mid); if(u){ hi=mid-1; } else{ lo=mid+1; } } cout<<lo; } /* 4 3 2 39 41 45 39 42 46 */
#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...