# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314274 | BeanZ | Just Long Neckties (JOI20_ho_t1) | C++14 | 370 ms | 18936 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 2e5 + 5;
pair<ll, ll> a[N];
ll b[N], ans[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("A.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n;
cin >> n;
for (int i = 1; i <= (n + 1); i++) cin >> a[i].first, a[i].second = i;
sort(a + 1, a + n + 1 + 1);
for (int i = 1; i <= n; i++) cin >> b[i];
sort(b + 1, b + n + 1);
multiset<ll, greater<ll>> s;
for (int i = 2; i <= (n + 1); i++){
s.insert(max(a[i].first - b[i - 1], 0ll));
}
ans[a[1].second] = *s.begin();
for (int i = 2; i <= (n + 1); i++){
s.erase(s.find(max(a[i].first - b[i - 1], 0ll)));
s.insert(max(a[i - 1].first - b[i - 1], 0ll));
ans[a[i].second] = *s.begin();
}
for (int i = 1; i <= (n + 1); i++){
cout << ans[i] << " ";
}
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |