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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define ff first
#define ss second
#define N 200002
#define MOD 1000000007
int a[N], ans[N];
vector<pair<int, int> > ne;
multiset<int> in;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i = 0; i <= n; ++i){
int k;
cin>>k;
ne.push_back({k, i});
}
sort(ne.begin(), ne.end());
for(int i = 0; i < n; ++i){
cin>>a[i];
}
sort(a, a + n);
for(int i = 0; i < n; ++i)
in.insert(a[i] - ne[i].ff);
ans[ne[n].ss] = *in.begin();
for(int i = n - 1; i >= 0; --i){
in.erase(in.find(a[i] - ne[i].ff));
in.insert(a[i] - ne[i + 1].ff);
ans[ne[i].ss] = *in.begin();
}
for(int i = 0; i <= n; ++i)
cout<<max(0, -ans[i])<<' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |