Submission #83176

#TimeUsernameProblemLanguageResultExecution timeMemory
83176heonCipele (COCI18_cipele)C++11
18 / 90
52 ms9596 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int l,r; cin >> l >> r; vector <int> a, b; for(int i = 0; i < l; i++){ int input; cin >> input; a.push_back(input); } for(int i = 0; i < r; i++){ int input; cin >> input; b.push_back(input); } sort(a.begin(),a.end()); sort(b.begin(),b.end()); if(l < r){ int first = a[0]; auto pt = upper_bound(b.begin(), b.end(), first); --pt; int ind = (pt - b.begin()); while(ind + l > r) ind--; int mx = 0; for(int i = 0; i < l; i++){ mx = max(mx, abs(a[i] - b[i + ind])); } cout << mx; } else if(r < l){ int first = b[0]; auto pt = upper_bound(a.begin(), a.end(), first); int ind = (pt - a.begin()); while(ind + r > l) ind--; int mx = 0; for(int i = 0; i < r; i++){ mx = max(mx, abs(b[i] - a[i + ind])); } cout << mx; } else{ int mx = 0; for(int i = 0; i < l; i++){ mx = max(mx, abs(a[i] - b[i])); } cout << mx; } }
#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...