Submission #897839

# Submission time Handle Problem Language Result Execution time Memory
897839 2024-01-03T19:25:04 Z arbuzick Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n);
    vector<pair<int, int>> a_s(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
        a_s[i] = {a[i], i};
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    sort(a_s.begin(), a_s.end());
    sort(b.begin(), b.end());
    vector<int> ans(n);
    vector<int> pr_ans(n + 1), suff_ans(n + 1);
    for (int i = 0; i < n; ++i) {
        pr_ans[i + 1] = max(pr_ans[i], a_s[i].first - b[i]);
    }
    for (int i = n; i > 0; --i) {
        suff_ans[i - 1] = max(suff_ans[i], a_s[i].first - b[i - 1]);
    }
    for (int i = 0; i < n + 1; ++i) {
        ans[a_s[i].second] = max(pr_ans[i], suff_ans[i]);
    }
    for (int i = 0; i < n + 1; ++i) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(25);
    cout << fixed;
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -