# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335618 | Joshc | Just Long Neckties (JOI20_ho_t1) | C++11 | 135 ms | 17620 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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
ll x[200002], y[200002], ans[200002], c;
int main() {
int n;
vector<pair<ll, ll> > a;
vector<ll> b;
scanf("%d", &n);
for (int i=0; i<=n; i++) {
scanf("%lld", &c);
a.emplace_back(c, i);
}
sort(a.begin(), a.end());
for (int i=0; i<n; i++) {
scanf("%lld", &c);
b.push_back(c);
}
sort(b.begin(), b.end());
for (int i=1; i<=n; i++) {
x[i] = max(a[i-1].first-b[i-1], x[i-1]);
y[i] = max(a[n-i+1].first-b[n-i], y[i-1]);
}
for (int i=0; i<=n; i++) ans[a[i].second] = max(x[i], y[n-i]);
for (int i=0; i<=n; i++) printf("%lld ", 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... |