# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
445612 | jamezzz | Just Long Neckties (JOI20_ho_t1) | C++17 | 144 ms | 7920 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, a, b[200005], c[200005], pmx[200005], smx[200005];
typedef pair<int, int> ii;
vector<ii> v;
int main(){
scanf("%d", &n);
for (int i = 0; i <= n; ++i){
scanf("%d", &a);
v.push_back(ii(a, i));
}
for (int i = 0; i < n; ++i){
scanf("%d", &b[i]);
}
sort(v.begin(), v.end());
sort(b, b + n);
int ans = 0;
for (int i = 1; i <= n; ++i){
ans = max(ans, v[i].first - b[i - 1]);
c[v[0].second] = ans;
}
int sfx = 0;
for (int i = n; i >= 1; --i){
sfx = max(sfx, v[i].first - b[i - 1]);
smx[i] = sfx;
}
smx[n + 1] = 0;
for (int i = 1; i <= n; ++i){
pmx[i] = max(pmx[i - 1], v[i - 1].first - b[i - 1]);
c[v[i].second] = max(pmx[i], smx[i + 1]);
}
for (int i = 0; i <= n; ++i){
printf("%d ", c[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... |