# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
529786 | Alex_tz307 | Just Long Neckties (JOI20_ho_t1) | C++17 | 88 ms | 10052 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;
void testCase() {
int n;
cin >> n;
vector<pair<int, int>> a(n + 2);
for (int i = 1; i <= n + 1; ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin() + 1, a.end());
vector<int> b(n + 2);
for (int i = 1; i <= n; ++i) {
cin >> b[i];
}
sort(b.begin() + 1, b.begin() + n + 1);
vector<int> sufMax(n + 2);
for (int i = n; i > 0; --i) {
sufMax[i] = max(a[i + 1].first - b[i], sufMax[i + 1]);
}
vector<int> sol(n + 2);
int pref = 0;
for (int i = 1; i <= n + 1; ++i) {
sol[a[i].second] = max(pref, sufMax[i]);
pref = max(pref, a[i].first - b[i]);
}
for (int i = 1; i <= n + 1; ++i) {
cout << sol[i] << ' ';
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |