Submission #413569

#TimeUsernameProblemLanguageResultExecution timeMemory
413569OzyJust Long Neckties (JOI20_ho_t1)C++17
9 / 100
1058 ms8500 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl

#define MAX 200000

lli n,res,paso,a;
lli ori[MAX+2],A[MAX+2],B[MAX+2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    rep(i,1,n+1) {
        cin >> A[i];
        ori[i] = A[i];
    }
    rep(i,1,n) cin >> B[i];

    sort(A+1, A+n+2);
    sort(B+1, B+n+1);

    rep(i,1,n+1) {
        paso = 0;
        res = 0;
        rep(j,1,n+1) {
            if (paso==0 && ori[i] == A[j]) {
                paso=1;
                continue;
            }

            a = A[j] - B[j-paso];
            if (a > res) res = a;

        }

        cout << res << ' ';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...