Submission #83462

#TimeUsernameProblemLanguageResultExecution timeMemory
83462charlies_mooCipele (COCI18_cipele)C++17
27 / 90
1089 ms1356 KiB
#include<iostream> #include<algorithm> #include<math.h> #include<stdlib.h> using namespace std; int l[100010],r[100010]; int main(){ int n,m,i,j,k; cin >> n >> m; for(i=1;i<=n;i++) cin >> l[i]; for(i=1;i<=m;i++) cin >> r[i]; sort(l+1,l+n+1); sort(r+1,r+m+1); if(n==m) { k=0; for(i=1;i<=n;i++) { if(abs(l[i]-r[i])>k) k=abs(l[i]-r[i]); } } else if(n>m) { i=1; int x=i+m; if(i+m>n) x=n; while(x<n && l[x]<r[0]) x++; i=x-m; k=-1; for(;i<=n-m+1;i++) { int y = 0; for(j=1;j<=m;j++){ if(abs(l[j+i-1]-r[j])>y) y=abs(l[j+i-1]-r[j]); } if(y<k || k==-1) k=y; if(l[i]>r[m]) break; } } else { i=1; int x=i+n; if(i+n>m) x=m; while(x<m && l[x]<r[0]) x++; i=x-n; k=-1; for(;i<=m-n+1;i++) { int y = 0; for(j=1;j<=n;j++){ if(abs(l[j]-r[j+i-1])>y) y=abs(l[j]-r[i+j-1]); } if(y<k || k==-1) k=y; if(r[i]>l[n]) break; } } cout << k << endl; 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...