Submission #855727

#TimeUsernameProblemLanguageResultExecution timeMemory
855727vjudge1Cipele (COCI18_cipele)C++17
18 / 90
31 ms1368 KiB
//author: Ahmet Alp Orakci #include <bits/stdc++.h> using namespace std; using i64 = long long; #define ONLINE_JUDGE void solve() { int n, m; cin >> n >> m; vector <int> a(n +1), b(m +1); for(int i = 1; i <= n; i++) cin >> a[i]; for(int j = 1; j <= m; j++) cin >> b[j]; if(n > m) { swap(a, b); swap(n, m); } sort(a.begin(), a.end()); sort(b.begin(), b.end()); auto check = [&](int c) -> bool { int ind = 1; for(int i = 1; i <= m; i++) { while(ind <= n && abs(a[i] - b[ind]) > c) ind++; if(ind == n +1) { return false; } ind++; } return true; }; int l = 0, r = 1E9, ans = 0; while(l <= r) { int mid = (l + r) / 2; if(check(mid)) { ans = mid; r = mid -1; } else { l = mid +1; } } cout << ans << "\n"; return; } signed main() { #ifndef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { 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...