Submission #253716

# Submission time Handle Problem Language Result Execution time Memory
253716 2020-07-28T15:00:45 Z Sorting Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
0 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

const int k_N = 2e5 + 3;

int n;
int a[k_N], b[k_N];
int prefix[k_N], suffix[k_N];

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

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

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

    for(int i = 1; i <= n; ++i)
        prefix[i] = max(prefix[i - 1], max(a[i] - b[i], 0));
    for(int i = n + 1; i >= 2; --i)
        suffix[i] = max(suffix[i + 1], max(a[i] - b[i - 1], 0));

    for(int i = 1; i <= n; ++i)
        cout << max(prefix[i - 1], suffix[i + 1]) << " ";
    cout << prefix[n];
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -