Submission #774404

# Submission time Handle Problem Language Result Execution time Memory
774404 2023-07-05T17:28:33 Z kirakaminski968 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int N; cin >> N;
    vector<int> arr(N+1);
    for(int i = 0;i<=N;++i) cin >> arr[i];
    sort(arr.begin(),arr.end());
    vector<int> brr(N);
    for(int i = 0;i<N;++i) cin >> brr[i];
    sort(brr.begin(),brr.end());
    vector<int> pref(N),suf(N);
    for(int i = 0;i<N;++i){
        if(i == 0){
            pref[i] = max(arr[i]-brr[i],0);
        }
        else{
            pref[i] = max(max(arr[i]-brr[i],0),pref[i-1]);
        }
        //cout << pref[i] << " ";
    }
    //cout << "\n";
    for(int i = N-1;i>=0;--i){
        if(i == N-1){
            suf[i] = max(arr[i+1]-brr[i],0);
        }
        else{
            suf[i] = max(max(arr[i+1]-brr[i],0),suf[i+1]);
        }
        //cout << suf[i] << " ";
    }
    //cout << "\n";
    vector<int> ans(N+1);
    for(int i = 0;i<=N;++i){
        if(i == 0) ans[i] = suf[i];
        else if(i == N) ans[i] = pref[N-1];
        else{
            ans[i] = max(suf[i],pref[i-1]);
        }
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -