Submission #239092

#TimeUsernameProblemLanguageResultExecution timeMemory
239092ioilolcomCipele (COCI18_cipele)C++14
0 / 90
91 ms13560 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int ll; set<int> s; int main() { ios_base:: sync_with_stdio(false); cin.tie(0); int n,m; cin>>n>>m; vector<int> v1(n+1),v2(m+1); for(int i=1; i<=n; i++) { cin>>v1[i]; } for(int i=1; i<=m; i++) { cin>>v2[i]; } if(m>n) { swap(n,m); swap(v1,v2); } for(int i=1; i<=n; i++) { s.insert(v1[i]); } //cout<<endl; sort(v2.rbegin(),v2.rend()-1); /* for(int i=1; i<=m; i++) { cout<<v2[i]<<" "; } cout<<endl; */ int ans=0; for(int i=1; i<=m; i++) { auto d=s.lower_bound(v2[i]); auto d2=d; d2--; if(abs(*d-v2[i])<abs(*d2-v2[i])) { ans=max(ans,abs(*d-v2[i])); s.erase(d); } else{ ans=max(ans,abs(*d2-v2[i])); s.erase(d2); } } cout<<ans<<endl; return 0; }
#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...