제출 #516275

#제출 시각아이디문제언어결과실행 시간메모리
516275thanh913Cipele (COCI18_cipele)C++14
27 / 90
40 ms4156 KiB
#include <bits/stdc++.h> using namespace std; //types #define ll long long #define ld long double #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second #define inf 0x3f3f3f3f #define pb(a) push_back(a) #define mp(a, b) make_pair(a, b) //lowercase 31, all 53 //(P/Q) % M = (P % M) * (Q^(M-2) % M) //------------------------------------------------------- const ll mx = 1e5+5, mod = 1e9+7; ll n, m; vector<ll> a, b; bool check(ll x) { ll i = n, j = m; while (i >= 1) { if (j < 1) return false; while (j >= 1) { if (abs(b[i] - a[j]) <= x) { j--; break; } else j--; } i--; } return true; } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> m; a.pb(-inf); b.pb(-inf); for (int i = 1; i <= n; i++) { int tmp; cin >> tmp; a.pb(tmp); } for (int i = 1; i <= m; i++) { int tmp; cin >> tmp; b.pb(tmp); } sort(a.begin()+1, a.end()); sort(b.begin()+1, b.end()); if (a.size() > b.size()) { swap(a, b); swap(n, m); } ll l = 0, r = 1e9, kq = 1e9; while (l <= r) { ll mid = (l+r) / 2; if (check(mid)) { r = mid - 1; kq = mid; } else l = mid + 1; } cout << kq; }
#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...