Submission #762944

# Submission time Handle Problem Language Result Execution time Memory
762944 2023-06-22T01:36:00 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define st first
#define nd second
const int maxn = 2e5 + 5;
int ans[maxn], a[maxn], b[maxn], st[maxn * 4], n;
void build(int id, int l, int r){
    if(l == r){
        st[id] = max(a[l + 1] - b[l], 0ll);
        return;
    }
    int m = (l + r) >> 1;
    build(id * 2, l, m);
    build(id * 2 + 1, m + 1, r);
    st[id] = max(st[id * 2], st[id * 2 + 1]);
}

void update(int id, int l, int r, int pos){
    if(l > pos || r < pos)
        return;
    if(l == r){
        st[id] = max(a[l] - b[l], 0ll);
        return;
    }
    int m = (l + r) >> 1;
    update(id * 2, l, m, pos);
    update(id * 2 + 1, m + 1, r, pos);
    st[id] = max(st[id * 2], st[id * 2 + 1]);
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    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 + n + 2);
    sort(b + 1, b + n + 1);
    build(1, 1, n);
    ans[1] = st[1];
    for(int i = 2 ; i <= n + 1 ; i++){
        update(1, 1, n, i - 1);
        ans[i] = st[1];
    }
    for(int i = 1 ; i <= n + 1 ; i++)
        cout << ans[i] << " ";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -