Submission #1132398

#TimeUsernameProblemLanguageResultExecution timeMemory
1132398Le_Minh_DucCipele (COCI18_cipele)C++20
27 / 90
26 ms1096 KiB
#include<bits/stdc++.h> #define ll long long #define lll __int128_t #define f first #define s second using namespace std; const int mod = 1e9 + 7; const int N = 1e5 + 5; const ll INF = 1e18 + 7; int n, m; vector<int> a(N), b(N); int cnt(int s){ int res = 0; for(int i = s; i <= s + m - 1; i++){ res = max(res, abs(a[i] - b[i - s + 1])); } return res; } bool check(int val){ for(int i = 1; i <= n - m + 1; i++){ if(abs(a[i] - b[1]) <= val){ return cnt(i) <= val; } } return 0; } signed main(){ // freopen(".inp", "r", stdin); // // freopen(".out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i = 1; i <= n; i++) cin>>a[i]; for(int i = 1; i <= m; i++) cin>>b[i]; if(n < m){ swap(n, m); swap(a, b); } sort(a.begin() + 1, a.begin() + n + 1); sort(b.begin() + 1, b.begin() + m + 1); int l = 0, r = 1e9, mid; while(l <= r){ int mid = (l + r) >> 1; if(check(mid)) r = mid - 1; else l = mid + 1; } cout<<l; }
#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...