Submission #1114674

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

using namespace std;

int granica(int x,  int v,int  y){
    return min(max(x, v), y); 
}

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

    int n; cin >> n;

    vector<int> a(n+1); 
    vector<int> b(n); 
    vector<int> pref(n+1, 0);
    vector<int> 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<int> res(n+1);

    int aktual =  0;
    for (int i = 0; i < n; i++){ // pref czyli jak usuwamy ity elem np. ostatni
        int 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
        int h = a[i+1] - b[i];
        aktual = max(aktual, h); 
        suf[i] = aktual; 
    }

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