# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227174 | ho94949 | Just Long Neckties (JOI20_ho_t1) | C++17 | 145 ms | 7400 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;
const int MAXN = 200'000;
pair<int, int> A[MAXN+1];
int B[MAXN];
int N;
int main()
{
scanf("%d", &N);
for(int i=0; i<N+1; ++i)
{
scanf("%d", &A[i].first);
A[i].second = i;
}
for(int i=0; i<N; ++i) scanf("%d", B+i);
sort(A, A+N+1); sort(B, B+N);
vector<int> p(1), q(1);
for(int i=0; i<N; ++i)
p.push_back(max(p.back(),A[i].first-B[i]));
for(int i=N-1; i>=0; --i)
q.push_back(max(q.back(),A[i+1].first-B[i]));
reverse(q.begin(), q.end());
vector<int> ans(N+1);
for(int i=0; i<=N; ++i)
ans[A[i].second] = max(p[i], q[i]);
for(int i=0; i<=N; ++i) printf("%d ", ans[i]);
puts("");
}
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... |