Submission #464755

#TimeUsernameProblemLanguageResultExecution timeMemory
464755Hamed5001Cipele (COCI18_cipele)C++14
18 / 90
44 ms2888 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> A1, A2; int N, M; void solve() { cin >> N >> M; A1.resize(N); A2.resize(M); for (auto& a : A1) cin >> a; for (auto& a : A2) cin >> a; sort(A1.begin(), A1.end()); sort(A2.begin(), A2.end()); if (N > M) { swap(N, M); swap(A1, A2); } int ans = 0, frm = 0; for (int i = 0; i < N; i++) { int it = lower_bound(A2.begin()+frm, A2.begin()+M-(N-i-1), A1[i]) - A2.begin(); int c1 = (it >= M ? INT_MAX : abs(A1[i] - A2[it])), c2 = (it == frm ? INT_MAX : abs(A1[i] - A2[it-1])); // cerr << it << ' ' << frm << ' ' << c1 << ' ' << c2 << endl; if (c1 < c2) ans = max(ans, c1), frm = it+1; else ans = max(ans, c2), frm = it; } cout << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); solve(); }
#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...