Submission #158775

#TimeUsernameProblemLanguageResultExecution timeMemory
158775a_playerCipele (COCI18_cipele)C++14
0 / 90
3 ms548 KiB
#include <bits/stdc++.h> using namespace std; int N,M; int r[100]; int l[100]; int corrisp[100]; int main() { cin>>N>>M; for(int i=0;i<N;i++)cin>>r[i]; for(int i=0;i<M;i++)cin>>l[i]; if(N>M){ swap(N,M); swap(r,l); } sort(r,r+N); sort(l,l+M); int a=0,b=M-1; for(int i=0;i<N/2;i++){ while(a<M-1){ if(abs(l[a]-r[i])>abs(l[a+1]-r[i])&&b-a-1>N-2*i-2)a++; else break; } while(b>0){ if(abs(l[b]-r[N-i-1])>abs(l[b-1]-r[N-i-1])&&b-a-1>N-2*i-2)b--; else break; } corrisp[i]=a; corrisp[N-i-1]=b; a++; b--; } if(N%2){ int mini=abs(l[a]-r[N/2]); int pos=a; for(int i=a+1;i<=b;i++){ if(mini>abs(l[i]-r[N/2])){ mini=abs(l[i]-r[N/2]); pos=i; } }corrisp[N/2]=pos;} int mini=abs(r[0]-l[corrisp[0]]); for(int i=1;i<N;i++)mini=max(abs(r[i]-l[corrisp[i]]),mini); cout<<mini; 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...