Submission #894387

#TimeUsernameProblemLanguageResultExecution timeMemory
894387vjudge1Cipele (COCI18_cipele)C++17
0 / 90
24 ms1164 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define pii pair<int, int> #define ppb pop_back() const int N = (int)1e5 + 5; const ll mod = (int)1e9 + 7; const ll inf = (1e9) + 100; int n, m; int a[N], b[N]; bool ok(int k) { int j = 1; for (int i = 1; i <= min(n, m); i++) { if (n <= m) { while (j <= m && abs(a[i] - b[j]) > k) j++; if (j > m) return 0; j++; } else { while (j <= n && abs(a[j] - b[i]) > k) j++; if (j > n) return 0; j++; } } return 1; } void solve() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) { cin >> b[i]; } int l = 0, r = inf, ans = inf; while (l <= r) { int mid = (l + r) / 2; if (ok(mid)) { r = mid - 1; ans = mid; } else l = mid + 1; } cout << ans; } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); 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...