Submission #855724

#TimeUsernameProblemLanguageResultExecution timeMemory
855724vjudge1Cipele (COCI18_cipele)C++17
90 / 90
44 ms1884 KiB
#include <bits/stdc++.h> using namespace std; #define sp << " " << #define int long long #define vi vector<int> #define pb push_back #define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++) #define pii pair<int,int> #define all(x) x.begin()+1,x.end() const int N = 4e5+1; void solve() { int n,m; cin >> n >> m; vi a(n+1),b(m+1); F(i,n) cin >> a[i]; F(i,m) cin >> b[i]; sort(a.begin(),a.end()); sort(b.begin(),b.end()); if (a.size() > b.size()) swap(a,b),swap(n,m); int l = 0; int r = 1e9; while (l<=r) { int x = (l+r) >> 1; int ptr2 = 1; stack<int> s; int fl = 1; for (int i=1;i<=n;i++) { while (ptr2<=m && (s.empty() || s.top() < a[i]-x)) s.push(b[ptr2++]); if (!s.empty() && s.top() >= a[i]-x && s.top() <= a[i]+x) { //cout << x sp s.top() sp a[i] << endl; while (!s.empty()) s.pop(); continue; } fl = 0; break; } //cout << x sp fl << endl; if (fl) r = x-1; else l = x+1; } cout << l << endl; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; while (t --> 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...