#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 2e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n, a[MAXN], b[MAXN];
void read()
{
cin >> n;
for (int i = 1; i <= n + 1; ++ i)
cin >> a[i];
for (int i = 1; i <= n; ++ i)
cin >> b[i];
sort(a+1, a+n+2);
sort(b+1, b+n+1);
}
long long dp0[MAXN], dp1[MAXN];
void solve()
{
for (int i = 1; i <= n; ++ i)
{
dp0[i] = dp0[i-1];
dp0[i] = max(dp0[i], max(1LL * 0, a[i] - b[i]));
//cout << dp0[i] << " ";
}
// cout << endl;
for (int i = n+1; i >= 1; -- i)
{
dp1[i] = dp1[i+1];
dp1[i] = max(dp1[i], max(1LL * 0, a[i] - b[i-1]));
}
for (int i = 1; i <= n+1; ++ i)
{
cout << max(dp0[i-1], dp1[i+1]) << " ";
}
cout << endl;
}
int main()
{
speed();
read();
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |