제출 #719091

#제출 시각아이디문제언어결과실행 시간메모리
719091thimote75Just Long Neckties (JOI20_ho_t1)C++14
0 / 100
0 ms212 KiB

#include <bits/stdc++.h>

using namespace std;

int nbTypes;

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

    cin >> nbTypes;    
    vector<int> a(nbTypes + 1);
    for (int iT = 0; iT <= nbTypes; iT ++)
        cin >> a[iT];
    vector<int> b(nbTypes);
    for (int jT = 0; jT < nbTypes; jT ++)
        cin >> b[jT];
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    vector<int> c(nbTypes + 1);
    vector<int> d(nbTypes + 1);
    for (int iT = 0; iT < nbTypes; iT ++) {
        c[iT]     = a[iT] - b[iT];
        d[iT + 1] = a[iT + 1] - b[iT];
    }

    for (int iT = 1; iT <= nbTypes; iT ++)
        c[iT] = max(c[iT], c[iT - 1]);
    for (int jT = nbTypes - 1; jT >= 0; jT --)
        d[jT] = max(d[jT + 1], d[jT]);
    
    for (int i = 0; i <= nbTypes; i ++) {
        int mu = i == 0 ? 0 : c[i - 1];
        int nu = i == nbTypes ? 0 : d[i + 1];

        cout << max(mu, nu);
        if (i != nbTypes) cout << " ";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...