Submission #170357

#TimeUsernameProblemLanguageResultExecution timeMemory
170357mdn2002Cipele (COCI18_cipele)C++14
72 / 90
63 ms3000 KiB
#include<bits/stdc++.h> using namespace std; const long long mod=998244353; int n,m,mx,a[100005],b[100005]; bool ck(int x) { if(n>=m) { int j=0; for(int i=0;i<n;i++) { int aa=max(a[i],b[j]); int bb=min(a[i],b[j]); if((n-i)<(m-j))return 0; if(aa-bb<=x)j++; if(j==m)break; } return 1; } else { int j=0; for(int i=0;i<m;i++) { int aa=max(a[j],b[i]); int bb=min(a[j],b[i]); if((n-j)>(m-i))return 0; if(aa-bb<=x)j++; if(j==n)break; } return 1; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen("lemonade.in","r",stdin); //freopen("lemonade.out","w",stdout); cin>>n>>m; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<m;i++)cin>>b[i]; sort(a,a+n); sort(b,b+m); int l=0,r=1e9+1,mid; while(l<r) { mid=(l+r)/2; if(ck(mid))r=mid; else l=mid+1; } cout<<l; }
#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...