# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244847 | maximath_1 | Just Long Neckties (JOI20_ho_t1) | C++11 | 185 ms | 7032 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;
#define ll long long
int n = 0;
vector<int> a, b, id, pos, pref, suff;
bool cmp(int x, int y){
return a[x] < a[y];
}
int main(){
scanf("%d", &n);
a.resize(n + 1); id.resize(n + 1); pos.resize(n + 1);
b.resize(n);
for(int i = 0; i <= n; i ++){
scanf("%d", &a[i]);
id[i] = i;
}
for(int i = 0; i < n; i ++)
scanf("%d", &b[i]);
sort(id.begin(), id.end(), cmp); sort(a.begin(), a.end());
for(int i = 0; i <= n; i ++)
pos[id[i]] = i;
sort(b.begin(), b.end());
pref.assign(n + 1, 0); suff.assign(n + 1, 0);
for(int i = 1; i <= n; i ++)
pref[i] = max(pref[i - 1], a[i - 1] - b[i - 1]);
for(int i = n - 1; i >= 0; i --)
suff[i] = max(suff[i + 1], a[i + 1] - b[i]);
for(int i = 0; i <= n; i ++)
printf("%d%c", max(pref[pos[i]], suff[pos[i]]), i == n ? '\n' : ' ');
return 0;
}
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... |