Submission #464655

#TimeUsernameProblemLanguageResultExecution timeMemory
464655ahmedfouadnewCipele (COCI18_cipele)C++17
45 / 90
521 ms262144 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back const int mod=1e9+7; int a[5005],b[5005],n,m; int dp[5005][5005]; int fun(int idx,int idx2) { if(idx2==m) { return 0; } if(idx==n) return 1e15; int &ret=dp[idx][idx2]; if(~ret) return ret; ret=1e15; ret=max(abs(a[idx]-b[idx2]),fun(idx+1,idx2+1)); ret=min(ret,fun(idx+1,idx2)); return ret; } signed main() { memset(dp,-1,sizeof dp); cin>>n>>m; for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<m;i++) { cin>>b[i]; } if(n<m) { for(int i=0;i<m;i++) { swap(a[i],b[i]); } swap(n,m); } sort(a,a+n); sort(b,b+m); cout<<fun(0,0)<<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...