Submission #1102806

#TimeUsernameProblemLanguageResultExecution timeMemory
1102806DanerZeinJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
149 ms10836 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; int main(){ int n; cin>>n; vector<ii> neck(n+1); vector<int> ori(n); int c=0; for(auto &v:neck) { cin>>v.first; v.second=c++; } for(auto &v:ori) cin>>v; sort(neck.begin(),neck.end()); sort(ori.begin(),ori.end()); vector<int> front(n),back(n); for(int i=0;i<n;i++){ front[i]=max( i>0?front[i-1]:0, max(neck[i].first-ori[i],0)); } for(int i=n-1;i>=0;i--){ back[i]=max( i<n-1?back[i+1]:0, max(neck[i+1].first-ori[i],0)); } vector<int> ans(n+1); for(int i=0;i<=n;i++){ ans[neck[i].second]=max( i>0?front[i-1]:0, i<n?back[i]:0); } for(auto &v:ans) cout<<v<<" "; cout<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...