Submission #745455

#TimeUsernameProblemLanguageResultExecution timeMemory
745455PacybwoahJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
441 ms21736 KiB
#include<iostream> #include<vector> #include<algorithm> #include<utility> #include<set> #define ll long long using namespace std; int main(){ int n; cin>>n; vector<ll> b(n); vector<pair<ll,ll>> a(n+1); for(int i=0;i<=n;i++) cin>>a[i].first; for(int i=0;i<n;i++) cin>>b[i]; sort(b.begin(),b.end()); for(int i=0;i<=n;i++) a[i].second=i; sort(a.begin(),a.end()); vector<ll> ans(n+1); multiset<ll> s; for(int i=0;i<n;i++) s.insert(a[i+1].first-b[i]); ans[a[0].second]=*prev(s.end()); for(int i=1;i<=n;i++){ s.erase(s.find(a[i].first-b[i-1])); s.insert(a[i-1].first-b[i-1]); ans[a[i].second]=*prev(s.end()); } for(auto x:ans) cout<<x<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...