Submission #197852

#TimeUsernameProblemLanguageResultExecution timeMemory
197852triplem5dsCipele (COCI18_cipele)C++14
90 / 90
162 ms3032 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include "bits/stdc++.h" using namespace std; #define pb push_back #define F first #define S second #define f(i,a,b) for(int i = a; i < b; i++) #define endl '\n' using ll = long long; using db = long double; using ii = pair<int, int>; const int N = 1e5 + 5, LG = 19, MOD = 1e9 + 7; const int SQ =320; const long double EPS = 1e-7; int n, m; vector<int> a, b; bool check(int limit){ for(int i = 0, j = 0; i < n; i++){ while(j < m && a[i] - b[j] > limit)j++; if(j == m || b[j] - a[i] > limit) return false; j++; } return true; } int32_t main(){ #ifdef ONLINE_JUDGE ios_base::sync_with_stdio(0); cin.tie(0); #endif cin >> n >> m; a.resize(n); b.resize(m); f(i,0,n) cin >> a[i]; f(i,0,m) cin >> b[i]; sort(a.begin(),a.end()); sort(b.begin(),b.end()); if(n > m){ swap(n, m); swap(a, b); } int lo = 0, hi = 1000 * 1000 * 1000; while(lo < hi){ int md = lo + (hi - lo) / 2; if(check(md)) hi = md; else lo = md + 1; } cout << lo << '\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...