Submission #385259

#TimeUsernameProblemLanguageResultExecution timeMemory
385259penguinhackerCipele (COCI18_cipele)C++14
90 / 90
49 ms3072 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int n, m, a[100000], b[100000]; bool ok(int x) { int c = 0; for (int i = 0, j = 0; i < n; ++i) { while(j < m && b[j] + x < a[i]) ++j; if (j == m) break; if (a[i] + x >= b[j]) ++c, ++j; } return c == min(n, m); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < m; ++i) cin >> b[i]; sort(a, a + n); sort(b, b + m); int l = 0, r = 1e9; while(l < r) { int mid = (l + r) / 2; if (ok(mid)) r = mid; else l = mid + 1; } cout << l; 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...