Submission #777382

#TimeUsernameProblemLanguageResultExecution timeMemory
7773821binJust Long Neckties (JOI20_ho_t1)C++14
0 / 100
0 ms340 KiB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 2e5 + 5;
ll n, a[NMAX], b[NMAX];
multiset<ll> s;

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i = 0; i <= n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n + 1);
    sort(b, b + n);
    for(int i = 0; i < n; i++) s.emplace(a[i + 1] - b[i]);
    cout << max(*s.rbegin(), 0LL) << ' ';
    for(int i = 0; i < n; i++){
        s.erase(s.find(a[i + 1] - b[i]));
        s.emplace(a[i] - b[i]);
        cout << max(*s.rbegin(), 0LL) << ' ';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...