Submission #366263

#TimeUsernameProblemLanguageResultExecution timeMemory
366263wiwihoCipele (COCI18_cipele)C++14
90 / 90
53 ms3072 KiB
#include <bits/stdc++.h> #define eb emplace_back #define printv(a, b) {\ bool ps = false;\ for(auto pv : a){\ if(ps) b << ' '; ps = true;\ b << pv;\ }\ b << "\n";\ } #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) using namespace std; int n, m; vector<int> a, b; int check(int k){ int now = 0; int ans = 0; for(int i = 0; i < n; i++){ while(now < m && b[now] < a[i] - k) now++; if(now < m && abs(b[now] - a[i]) <= k){ ans++; now++; } } //cerr << "check " << k << " " << ans << "\n"; return ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); 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]; lsort(a); lsort(b); int l = 0, r = 1000000000; while(l < r){ int mid = (l + r) / 2; if(check(mid) == min(n, m)) r = mid; else l = mid + 1; } cout << l << "\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...