# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208980 | davitmarg | Just Long Neckties (JOI20_ho_t1) | C++17 | 159 ms | 6264 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.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
const int N = 200005;
int n, b[N], sf[N], pr[N];
pair<int, int> a[N];
int main()
{
cin >> n;
for (int i = 1; i <= n + 1; i++)
{
scanf("%d", &a[i].first);
a[i].second = i;
}
for (int i = 1; i <= n; i++)
scanf("%d", b + i);
sort(a + 1, a + 1 + n + 1);
sort(b + 1, b + 1 + n);
for (int i = 1; i <= n; i++)
pr[i] = max(pr[i - 1], a[i].first - b[i]);
for (int i = n; i >= 1; i--)
sf[i] = max(sf[i + 1], a[i + 1].first - b[i]);
for (int i = 0; i <= n; i++)
b[a[i + 1].second] = max(pr[i], sf[i + 1]);
for (int i = 1; i <= n + 1; i++)
printf("%d ", b[i]);
cout << endl;
return 0;
}
/*
10
5 3 5 2 3 6 9 7 3 90 12
3 6 9 8 5 2 4 6 3 5
*/
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... |