Submission #855715

#TimeUsernameProblemLanguageResultExecution timeMemory
855715vjudge1Cipele (COCI18_cipele)C++17
0 / 90
706 ms14000 KiB
//author: Ahmet Alp Orakci #include <bits/stdc++.h> using namespace std; using i64 = long long; #define int i64 #define ONLINE_JUDGE void solve() { int n, m; cin >> n >> m; vector <int> a(n +1), b(m +1); for(int i = 1; i <= n; i++) { cin >> a[i]; } for(int i = 1; i <= m; i++) { cin >> b[i]; } if(n < m) { swap(a, b); swap(n, m); } multiset <i64> ms(b.begin() +1, b.end()); ms.emplace(-1E18); ms.emplace(1E18); sort(a.begin(), a.end()); int ans = 0; for(int i = 1; i <= n; i++) { auto it = prev(ms.lower_bound(a[i])); auto it2 = next(it); cerr << a[i] << " :: " << *it << " " << *it2 << "\n"; if(a[i] - *it <= *it2 - a[i]) { ans = max(ans, a[i] - *it); ms.erase(it); } else { ans = max(ans, *it2 - a[i]); ms.erase(it2); } } cout << ans; return; } signed main() { #ifndef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { solve(); } 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...