Submission #85431

#TimeUsernameProblemLanguageResultExecution timeMemory
85431VicktorCipele (COCI18_cipele)C++14
18 / 90
1082 ms14012 KiB
#include <iostream> #include <algorithm> using namespace std; int N,M; long long A[100000],B[100000],K,T,F[100000],k,R; long long Q(int q,int w) { if (q==N) { R=0; for (int i=0;i<k;i++) R=max(R,F[i]); T=min(T,R); } else { for (int i=w;i<M;i++) { K=A[q]-B[i]; if (K<0) K*=-1; F[k]=K; k++; Q(q+1,i+1); k--; } } return 0; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); 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); if (N==M) { for (int i=0;i<N;i++) { K=A[i]-B[i]; if (K<0) K*=-1; T=max(K,T); } cout<<T; } else { T=10000000000000; if (M<N) for (int i=0;i<N;i++) swap(A[i],B[i]); Q(0,0); cout<<T; } 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...