#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "
#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back
void print(vi &temp) {
for (auto x : temp)
cout << x << ' ';
cout << nl;
}
void solve() {
int n;
cin >> n;
vi a(n+1), b(n);
for (auto &x : a)
cin >> x;
for (auto &x : b)
cin >> x;
sort(b.begin(), b.end());
// print(b);
vi ans;
for (int i = 0; i < n + 1; ++i) {
vi temp;
for (int j = 0; j < n + 1; ++j) {
if (i == j) continue;
temp.pb(a[j]);
}
sort(temp.begin(), temp.end());
// print(temp);
ll mx = 0;
for (int j = 0; j < n; ++j) {
mx = max(mx, max(temp[j] - b[j], 0LL));
}
ans.pb(mx);
}
print(ans);
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |