This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// In the name of God
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())
const int maxn = 2e5 + 5;
const int inf = 1e9 + 7;
int n, b[maxn], ans[maxn];
pii a[maxn];
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 0; i < n + 1; i++){
cin >> a[i].F;
a[i].S = i;
}
for(int i = 0; i < n; i++) cin >> b[i];
sort(b, b + n);
sort(a, a + n + 1);
multiset<int> st;
for(int i = 0; i < n; i++) st.insert(max(0, a[i + 1].F - b[i]));
for(int i = 0; i < n + 1; i++){
ans[a[i].S] = (*st.rbegin());
if(i != n) st.erase(st.find(max(0, a[i + 1].F - b[i])));
st.insert(max(0, a[i].F - b[i]));
}
for(int i = 0; i < n + 1; i++) cout << ans[i] << ' ';
cout << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |