Submission #896837

#TimeUsernameProblemLanguageResultExecution timeMemory
896837ace5Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
223 ms21076 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; ll ans[n+1]; int ind[n+2]; ll a[n+2],b[n+1]; multiset<ll> c; for(int i = 0;i < n+1;++i) { cin >> a[i]; ind[i] = i; } sort(ind,ind + n + 1,[&](int x,int y){return a[x] < a[y];}); for(int i = 0;i < n;++i) cin >> b[i]; sort(b,b+n); for(int i = 0;i < n;++i) { c.insert(-max(0ll,a[ind[i+1]] - b[i])); } for(int i =0;i < n;++i) { ans[ind[i]] = -(*c.begin()); c.erase(c.find(-max(0ll,a[ind[i+1]] - b[i]))); c.insert(-max(0ll,a[ind[i]] - b[i])); } ans[ind[n]] = -(*c.begin()); for(auto c:ans) cout << c << ' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...