#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using str = string;
using ld = long double;
using hash_map = gp_hash_table<int, int>;
using hash_set = gp_hash_table<int, null_type>;
auto sd = std::chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(sd);
using ord_set = tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
const ll inf = 1e18;
void solve1() {
ll n;
cin >> n;
vector<ll> a(n+1);
for (int i = 0; i <= n; i++){
cin>>a[i];
}
vector<ll> a1 = a;
sort(a1.begin(), a1.end());
vector<ll> b(n);
for (int i =0; i<n;i++){
cin>>b[i];
}
sort(b.begin(), b.end());
for (int i =0; i <n+1; i++){
bool del = 0;
vector<ll> a2;
for(int j = 0; j< n+1; j++){
if (a1[j]==a[i]&&!del){
del = true;
}
else {
a2.push_back(a1[j]);
}
}
ll MX= 0;
for(int q =0; q<n ;q++) MX= max(MX, a2[q]-b[q]);
cout<<MX<<" ";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef local
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int t1 = 1;
// cin>>t1;
for (int o_ = 0; o_ < t1; o_++) {
solve1();
}
#ifdef local
printf_s("\n%.5f s", (double) clock() / CLOCKS_PER_SEC);
#endif
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |