#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N; cin >> N;
vector<int> A(N+1), B(N);
for(int i = 0;i<=N;++i) cin >> A[i];
for(int i = 0;i<N;++i) cin >> B[i];
sort(A.begin(),A.end()); sort(B.begin(),B.end());
vector<int> pref(N);
for(int i = 0;i<N;++i){
if(i != 0) pref[i] = max(pref[i-1],max(A[i]-B[i],0));
else pref[i] = max(A[i]-B[i],0);
//cout << pref[i] << "\n";
}
vector<int> suf(N+1);
for(int i = N;i>=1;--i){
if(i != N) suf[i] = max(suf[i+1],max(A[i]-B[i-1],0));
else suf[i] = max(A[i]-B[i-1],0);
}
for(int i = 0;i<=N;++i){
if(i != N && i != 0) cout << max(suf[i+1],pref[i]) << " ";
else if(i == N) cout << pref[i-1] << "\n";
else cout << suf[i+1] << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |