Submission #1132392

#TimeUsernameProblemLanguageResultExecution timeMemory
1132392Le_Minh_DucCipele (COCI18_cipele)C++20
27 / 90
23 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, a[N], b[N]; int cnt(int s){ if(s == 0) return 2e9; int res = 0; for(int i = s; i <= s + m - 1; i++){ res = max(res, abs(a[i] - b[i - s + 1])); } return res; } 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 + 1, a + n + 1); sort(b + 1, b + m + 1); int ans = 2e9; for(int i = 1; i <= n - m + 1; i++){ if(i == n - m + 1 || a[i] >= b[1]){ ans = min(ans, min(cnt(i - 1), cnt(i))); break; } } cout<<ans; }
#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...