Submission #916774

#TimeUsernameProblemLanguageResultExecution timeMemory
916774sandrofeiqrishviliCipele (COCI18_cipele)C++14
90 / 90
87 ms2996 KiB
#include <bits/stdc++.h> using namespace std; int n, m; vector <int> a, b; int check(int mid) { int j=0; for(int i=0; i<n; i++){ while(abs(b[j]-a[i])>mid){ j++; if (j == m) return false; } j++; if (j == m && i != n - 1) return false; } return true; } int main(){ cin >> n >> m; a.resize(n); b.resize(m); for(int i=0; i<n; i++){ cin >> a[i]; } for(int i=0; i<m; i++){ cin >> b[i]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); if (n > m) { swap(n, m); swap(a, b); } int l=0, r=1e9, ans = -1; while (l<=r) { int mid=(l+r)/2; if (check(mid)) { ans = mid; r = mid - 1; } else l = mid + 1; } cout << ans; }
#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...