Submission #783294

# Submission time Handle Problem Language Result Execution time Memory
783294 2023-07-14T19:49:48 Z borisAngelov Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 200005;

int n;

pair<int, int> a[maxn];
int b[maxn];

int answer[maxn];

int preffix[maxn];
int suffix[maxn];

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n;

    for (int i = 1; i <= n + 1; ++i)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    for (int i = 1; i <= n; ++i)
    {
        cin >> b[i];
    }

    sort(a + 1, a + n + 2);
    sort(b + 1, b + n + 1);

    for (int i = 1; i <= n; ++i)
    {
        preffix[i] = max(preffix[i - 1], a[i].first - b[i]);
    }

    for (int i = n; i >= 1; --i)
    {
        suffix[i] = max(suffix[i + 1], a[i + 1].first - b[i]);
    }

    for (int i = 1; i <= n; ++i)
    {
        answer[a[i].second] = max(preffix[i - 1], suffix[i]);
    }

    for (int i = 1; i <= n + 1; ++i)
    {
        cout << answer[i] << ' ';
    }

    cout << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -