# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
286141 | reymontada61 | Just Long Neckties (JOI20_ho_t1) | C++14 | 639 ms | 18680 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.
#include <bits/stdc++.h>
using namespace std;
int n;
const int MXN = 200005;
pair<int, int> arr[MXN];
int brr[MXN];
multiset<int> pairs;
void join(int a, int b) {
int x = max(0, arr[a].first - brr[b]);
pairs.insert(x);
}
void unjoin(int a, int b) {
int x = max(0, arr[a].first - brr[b]);
pairs.erase(pairs.lower_bound(x));
}
int score() {
return *(--pairs.end());
}
signed main() {
cin >> n;
for (int i=1; i<=n+1; i++) {
cin >> arr[i].first;
arr[i].second = i;
}
for (int i=1; i<=n; i++) {
cin >> brr[i];
}
sort(arr+1, arr+n+2);
sort(brr+1, brr+n+1);
for (int i=1; i<=n; i++) {
join(i+1, i);
}
vector<int> ans(n+2);
ans[arr[1].second] = score();
for (int i=1; i<=n; i++) {
unjoin(i+1, i);
join(i, i);
ans[arr[i+1].second] = score();
}
for (int i=1; i<=n+1; i++) cout << ans[i] << ' '; cout << endl;
}
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... |