Submission #237166

#TimeUsernameProblemLanguageResultExecution timeMemory
237166wwddJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
132 ms10720 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pl; typedef vector<ll> vl; typedef vector<pl> vpl; int main() { ios::sync_with_stdio(0);cin.tie(0); ll n; cin >> n; vpl w; vl x; for(int i=0;i<n+1;i++) { ll t; cin >> t; w.push_back({t,i}); } sort(w.begin(),w.end()); for(int i=0;i<n;i++) { ll t; cin >> t; x.push_back(t); } sort(x.begin(),x.end()); vl res(n+1,-1); ll rr = 0; for(int i=0;i<n;i++) { rr = max(rr,w[i].first-x[i]); res[i+1] = max(res[i+1],rr); } rr = 0; for(int i=n-1;i>=0;i--) { rr = max(rr,w[i+1].first-x[i]); res[i] = max(res[i],rr); } vl ans(n+1); for(int i=0;i<=n;i++) { ans[w[i].second] = res[i]; } for(int i=0;i<=n;i++) { if(i > 0) {cout << " ";} cout << ans[i]; } cout << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...