# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941875 | Litusiano | Just Long Neckties (JOI20_ho_t1) | C++14 | 188 ms | 15580 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n; cin>>n;
int cnt = 0;
vector<pair<int,int>> v(n+1); for(auto& i : v) cnt++,cin>>i.first, i.second = cnt-1;
vector<int> b(n); for(int& i : b) cin>>i;
sort(b.begin(),b.end());
// cout<<endl;
vector<int> ans(n+1);
sort(v.begin(),v.end());
vector<int> pre(n+1,0), suf(n+1,0);
for(int i = 0; i<n; i++){
pre[i+1] = max(pre[i], v[i].first-b[i]);
}
for(int i = n-1; i>=0; i--){
suf[i] = max(suf[i+1], v[i+1].first - b[i]);
}
// for(int i : pre) cout<<i<<" ";
// cout<<endl;
// for(int i : suf) cout<<i<<" "; cout<<endl;
for(int i = 0; i<=n; i++){
ans[v[i].second] = max(pre[i], suf[i]);
}
for(int i : ans) cout<<i<<" "; cout<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |