제출 #1136317

#제출 시각아이디문제언어결과실행 시간메모리
1136317lopkusCipele (COCI18_cipele)C++20
27 / 90
1095 ms1864 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n + 1); vector<int> b(m + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; } for(int i = 1; i <= m; i++) { cin >> b[i]; } sort(a.begin() + 1, a.end()); sort(b.begin() + 1, b.end()); if(n == m) { int ans = 0; for(int i = 1; i <= n; i++) { ans = max(ans, abs(a[i] - b[i])); } cout << ans; return 0; } if(n < m) { swap(a, b); swap(n, m); } int ans = 1e18; int k = n - m; for(int i = 1; i + k - 1 <= n; i++) { int e1 = 1; int e2 = 1; int current = 0; while(e1 <= n && e2 <= m) { if(e1 >= i && e1 <= i + k - 1) { e1 += 1; continue; } current = max(current, abs(a[e1++] - b[e2++])); } ans = min(ans, current); } 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...