Submission #472257

#TimeUsernameProblemLanguageResultExecution timeMemory
472257HossamHero7Cipele (COCI18_cipele)C++14
27 / 90
1095 ms1068 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' void solve(){ int n,m; cin>>n>>m; vector <int> v1(n); vector <int> v2(m); for(auto &i:v1) cin>>i; for(auto &i:v2) cin>>i; sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); if(n<m){ ll ANS = 1e18; for(int i=0;i<m-(n-1);i++){ ll cnt = 0; ll ans = 0; for(int j=i;j<n+i;j++){ ans = max((ll)abs(v2[j]-v1[cnt++]),ans); } ANS = min(ANS,ans); } cout<<ANS<<endl; } else { ll ANS = 1e18; for(int i=0;i<n-(m-1);i++){ ll cnt = 0; ll ans = 0; for(int j=i;j<m+i;j++){ ans = max((ll)abs(v1[j]-v2[cnt++]),ans); } ANS = min(ANS,ans); } cout<<ANS<<endl; } } int main() { int t=1; // cin>>t; while(t--){ solve(); } 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...