Submission #940887

#TimeUsernameProblemLanguageResultExecution timeMemory
940887LittleOrangeJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
76 ms13908 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(0);cin.tie(0); ll n; cin >> n; vector<ll> a(n+1),b(n); for(ll &i : a) cin >> i; for(ll &i : b) cin >> i; sort(b.begin(),b.end()); vector<pair<ll,ll>> c(n+1); for(ll i = 0;i<=n;i++) c[i] = {a[i],i}; sort(c.begin(),c.end()); ll cur = 0; vector<ll> ans(n+1); for(ll i = 0;i<n;i++) cur = max({cur,0ll,c[i].first-b[i]}); for(ll i = n;i>=0;i--){ ans[c[i].second] = cur; if(i){ cur = max({cur,0ll,c[i].first-b[i-1]}); } } for(ll i = 0;i<=n;i++) cout << ans[i] << " \n"[i==n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...