#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define ROF(i,m,n) for(int i=m;i<=n;i++)
#define vi vector<int>
#define pb push_back
#define alle(a) a.begin(),a.end()
#define rall(n) rbegin(n),rend(n)
#define int long long
#define vecs vector<int>
#define ll long long
#define ss second
#define ff first
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int N = 2005;
void solve(){
int n;
cin >> n;
int dp1[N], dp2[N],B[N], ans[N];
pair<int,int> A[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(B + 1, B + n + 1);
sort(A + 1, A + n + 2);
for(int i = 1; i <= n; ++i) {
dp1[i] = max(dp1[i - 1], A[i].first - B[i]);
}
for(int i = n + 1; i >= 2; --i) {
dp2[i] = max(dp2[i + 1], A[i].first - B[i]);
}
for(int i = 1; i <= n + 1; ++i) {
ans[A[i].second] = max(dp1[i - 1], dp2[i + 1]);
}
for(int i = 1; i <= n + 1; ++i) {
cout << ans[i] << ' ';
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1;
while (t--) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |