Submission #245902

#TimeUsernameProblemLanguageResultExecution timeMemory
245902alradCipele (COCI18_cipele)C++17
90 / 90
58 ms3072 KiB
#include <bits/stdc++.h> using namespace std; #define N (int)1e9 + 1 #define all(x) x.begin(), x.end() int main() { #ifdef judge ifstream cin("input.txt"); //ofstream cout("output.txt"); #endif // judge ios_base :: sync_with_stdio(0); cin.tie(0) , cout.tie(0); int n , m; cin >> n >> m; vector<int> a(n) , b(m); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { cin >> b[i]; } sort(all(a)) , sort(all(b)); if (n > m) { swap(n , m); swap(a , b); } auto can = [&](int x) { bool ok = true; int j = 0; for (int i = 0; i < n; i++) { while (j < m && abs(a[i] - b[j]) > x) { j++; } if (j >= m) { ok = false; break; } j++; } return ok; }; int l = 0 , r = N; while (l != r) { int mid = (l + r) >> 1; if (can(mid)) r = mid; else l = mid + 1; } cout << r << '\n'; 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...