Submission #643212

#TimeUsernameProblemLanguageResultExecution timeMemory
643212kdn5549Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
111 ms15436 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #define eb emplace_back #define all(v) v.begin(),v.end() #define ff first #define ss second const ll mxn=2e5+5; ll b[mxn],rt[mxn],pr[mxn],su[mxn]; pl a[mxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); ll n; cin>>n; for (int i=1;i<=n+1;i++) cin>>a[i].ff,a[i].ss=i; for (int i=1;i<=n;i++) cin>>b[i]; sort(a+1,a+n+2); sort(b+1,b+n+1); for (int i=1;i<=n;i++) pr[i]=max(pr[i-1],a[i].ff-b[i]); for (int i=n;i>=1;i--) su[i]=max(su[i+1],a[i+1].ff-b[i]); for (int i=1;i<=n+1;i++) rt[a[i].ss]=max(pr[i-1],su[i]); for (int i=1;i<=n+1;i++) cout<<rt[i]<<' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...