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>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 200*1000+10;
int n;
pi a[nax];
int b[nax];
int ans[nax];
priority_queue<pi>PQ;
int main() {_
cin>>n;
for(int i=1; i<=n+1; i++) {
cin>>a[i].ST;
a[i].ND = 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=2; i<=n+1; i++) {
PQ.push({a[i].ST-b[i-1],i});
}
for(int i=1; i<=n+1; i++) {
ans[a[i].ND] = max(0,PQ.top().ST);
PQ.push({a[i].ST-b[i],i+n+1});
while(!PQ.empty()&&PQ.top().ND<=i+1) {
PQ.pop();
}
}
for(int i=1; i<=n+1; i++) {
cout<<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... |