Submission #1114713

# Submission time Handle Problem Language Result Execution time Memory
1114713 2024-11-19T13:03:54 Z tkwiatkowski Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long

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

    ll n; cin >> n;

    vector<ll> a(n+1); 
    vector<ll> b(n); 
    vector<ll> pref(n+1, 0);
    vector<ll> suf(n+1, 0); 

    for (int i = 0; i <= n; i++){
        cin >> a[i]; 
    }
    for (int i = 0; i < n; i++){
        cin >> b[i]; 
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    vector<ll> res(n+1);

    ll aktual =  0;
    for (int i = 0; i < n; i++){ // pref czyli jak usuwamy ity elem np. ostatni
        ll h = a[i] - b[i];
        aktual = max(aktual, h); 
        pref[i] = aktual;  
    }
    res[n] = aktual; 
    
    aktual = 0;
    for (int i = n-1; i > 0; i--){ // suf co jak zabierzemy ity elem laczymy na skos
        ll h = a[i+1] - b[i];
        aktual = max<ll>(aktual, h); 
        suf[i] = aktual; 
    }

    res[0] = aktual; 
    for (int i = 1; i < n; i++){ // zabieramy ity
        ll h = max<ll>(pref[i-1], suf[i]); 
        res[i] = h; 
    }
    
    for (int i = 0; i <= n; i++){
        cout << res[i] << ' ';
    }
}
# 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 -