제출 #1299707

#제출 시각아이디문제언어결과실행 시간메모리
1299707azamuraiJust Long Neckties (JOI20_ho_t1)C++20
9 / 100
292 ms580 KiB
#include <bits/stdc++.h>

#define int long long
#define fi first
#define se second
#define mp make_pair
#define Sz(x) (int)x.size()

using namespace std;

const int N = 2005;
int n, a[N], b[N];

void solve() {
    cin >> n;
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    for (int i = 1; i <= n + 1; i++) {
        int ans = 0;
        vector <int> c, d;
        for (int j = 1; j < i; j++) c.push_back(a[j]);
        for (int j = i + 1; j <= n + 1; j++) c.push_back(a[j]);
        for (int j = 1; j <= n; j++) d.push_back(b[j]);
        sort(c.begin(), c.end());
        sort(d.begin(), d.end());
        for (int j = 0; j < n; j++) {
            ans = max(ans, max(0ll, c[j] - d[j]));
        }
        cout << ans << ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tt = 1;
    // cin >> tt;

    while (tt--) {
        solve();
        // cout << '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...