Submission #1117502

# Submission time Handle Problem Language Result Execution time Memory
1117502 2024-11-23T19:43:32 Z heey Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> a;


bool cmp(int l, int r){
    return a[l] < a[r];
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<int> b(n);
    a = vector<int>(n+1);
    for(int i = 0; i < n+1; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];


    sort(b.begin(), b.end());

    vector<int> c(n+1);
    for(int i = 0; i < n+1; i++) c[i] = i;

    sort(c.begin(), c.end(), cmp);

    vector<int> p(n), s(n);
    p[0] = max(a[c[0]] - b[0], 0ll);

    for(int i = 1; i < n; i++){
        p[i] = max(p[i-1], max(a[c[i]] -  b[i], 0ll));
    }

    s[n-1] = max(a[c[n]] - b[n-1], 0ll);
    for(int i = n - 2; i >= 0; i--) s[i] = max(s[i+1], max(a[c[i+1]] - b[i], 0ll));


    /*cout << "prefix\n";
    for(int i = 0; i < n; i++) cout << p[i] << ' ';
    cout << "\nsuffix\n";
    for(int i = 0; i < n; i++) cout << s[i] << ' ';
    cout << '\n';*/



    for(int i = 0; i < n+1; i++){
        if(c[i] == 0) cout << s[0] << ' ';
        else if(c[i] == n) cout << p[n-1] << ' ';
        else cout << max(p[c[i]], s[c[i]]) << ' ';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -