#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define sz size()
#define push_ push_back
vector <int> a,b;
int sf[200005];
int pr[200005];
signed main(){
int n,x;
sf[0]=0;
cin>>n;
a.push_back(0);
b.push_back(0);
for (int i=1; i<=n+1; i++){
cin>>x;
a.push_back(x);
}
auto c = a;
for (int i=1; i<=n; i++){
cin>>x;
b.push_back(x);
}
sort (a.begin(),a.end());
sort (b.begin(),b.end());
sf[n+1]=0;
for (int i=b.size()-1; i>0; i--){
int h=(a[i+1]-b[i]);
sf[i]=max(sf[i+1],max(0,h));
}
pr[0]=0;
for (int i=1; i<=n; i++){
pr[i]=max(pr[i-1],max(0,(a[i]-b[i])));
}
// for (int i=1; i<=n; i++){
// cout<<pr[i]<<" ";
// }cout << "\n";
// for (int i = 1; i <= n; i++) {
// cout << sf[i] << " ";
// }cout << "\n";
for (int i=0; i<=n; i++){
int p = lower_bound(c.begin(), c.end(), a[i + 1]) - c.begin();
cout<<max(pr[p - 1],sf[p])<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |