#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 2e5 + 69;
ll n;
pair<ll,ll> a[maxn];
ll b[maxn];
multiset<ll> s;
int main(){
cin >> n;
for(int i = 1 ;i<=n+1;i++){
cin >> a[i].first;
a[i].second = 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 = 1;i<=n+1;i++){
cout << a[i].first << " ";
}
cout << endl;
for(int i = 1;i<=n;i++){
cout << b[i] << " ";
}
cout << endl;
for(int i = 1;i<=n;i++){
s.insert(max(0ll,a[i+1].first - b[i]));
}
vector<ll> ans(n+1);
ans[a[1].second-1] = *s.rbegin();
for(int i = 1;i<=n;i++){
s.erase(s.find(max(a[i+1].first - b[i],0ll)));
s.insert(max(0ll,a[i].first - b[i]));
ans[a[i+1].second-1] = *s.rbegin();
}
for(auto i:ans) cout << i << " ";
}
# |
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 |
- |