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
#define F first
#define S second
#define el endl
#define cout(x) for(auto v:x)cout<<v<<' '
#define cin(x) for(auto &v:x)cin>>v;
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
vector<pair<int,int>>v;
int b[n];
for(int i=0;i<=n;i++){
int x;cin>>x;
v.push_back({x,i});
}
sort(all(v));
cin(b);
sort(b,b+n);
multiset<int>s;
for(int i=0;i<n;i++){
// cout<<b[i]<<' '<<v[i].F<<el;
s.insert(v[i].F-b[i]);
}
int ans[n+1]={};
ans[v[n].S]=*prev(s.end());
for(int i=n-1;i>=0;i--){
s.erase(s.find(v[i].F-b[i]));
s.insert(v[i+1].F-b[i]);
ans[v[i].S]=*prev(s.end());
}
cout(ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |