Submission #855718

#TimeUsernameProblemLanguageResultExecution timeMemory
855718vjudge1Cipele (COCI18_cipele)C++17
0 / 90
72 ms2844 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.top() >= a[i]-x && s.top() <= a[i]+x) continue; fl = 0; break; } 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...