Submission #472398

#TimeUsernameProblemLanguageResultExecution timeMemory
472398BidoTeimaCipele (COCI18_cipele)C++17
90 / 90
682 ms10112 KiB
/// isA AC #include <bits/stdc++.h> using namespace std; using ll = long long; void ACPLS(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } #define tc int tttttt;cin>>tttttt;while(tttttt--) #define sumrange(l,r,arr) (l==0?arr[r]:arr[r]-arr[l-1]) bool isint(const string& s){ bool ok=1; for(char i:s) ok&=isdigit(i); return ok; } bool isseq(const string& s){ return !isint(s); } int main(){ ACPLS(); int n,m; cin>>n>>m; vector<int>a; if(n<=m){ a.resize(n); for(auto&i:a)cin>>i; multiset<int>b; for(int i = 0; i < m; i++){ ll x; cin>>x; b.insert(x); } int lo=0,hi=1e9,ans=hi; sort(a.begin(), a.end()); while(lo<=hi){ ll mid=(lo+hi)/2; multiset<int>ms=b; bool ok = 1; for(int i = 0; i < n; i++){ if(ms.empty())break; auto it = ms.lower_bound(a[i]-mid); if(it==ms.end()||abs((*it)-a[i])>mid){ ok=0; break; } ms.erase(it); } if(ok){ ans=mid; hi=mid-1; }else lo=mid+1; } cout<<ans; } else{ a.resize(m); multiset<int>b; for(int i = 0; i < n; i++){ ll x; cin>>x; b.insert(x); } for(auto&i:a)cin>>i; int lo=0,hi=1e9,ans=hi; sort(a.begin(), a.end()); while(lo<=hi){ ll mid=(lo+hi)/2; multiset<int>ms=b; bool ok = 1; for(int i = 0; i < m; i++){ if(ms.empty())break; auto it = ms.lower_bound(a[i]-mid); if(it==ms.end()||abs((*it)-a[i])>mid){ ok=0; break; } ms.erase(it); } if(ok){ ans=mid; hi=mid-1; }else lo=mid+1; } 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...