Submission #679132

#TimeUsernameProblemLanguageResultExecution timeMemory
679132Charizard2021Cipele (COCI18_cipele)C++17
90 / 90
104 ms4232 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5; int n, m; vector<ll> L, R; bool works(ll x){ int cnt = 0; for(int i = 0; i < m; i ++){ if(cnt >= n){ return true; } if(llabs(R[i] - L[cnt]) > x){ continue; } cnt ++; } return (cnt >= n); } int main() { cin >> n >> m; ll num; for(int i = 0; i < n; i ++){ cin >> num; L.push_back(num); } for(int i = 0; i < m; i ++){ cin >> num; R.push_back(num); } if(n > m){ swap(L, R); } n = (int)L.size(); m = (int)R.size(); sort(L.begin(), L.end()); sort(R.begin(), R.end()); ll lo = 0, hi = (1LL << 40LL); ll ans = -1; while(lo <= hi){ ll mid = lo + ((hi - lo) / 2LL); if(works(mid)){ hi = mid -1; ans = mid; } else{ lo = mid +1; } } cout << ans << endl; 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...