Submission #1342846

#TimeUsernameProblemLanguageResultExecution timeMemory
1342846tamir1Just Long Neckties (JOI20_ho_t1)C++20
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
using namespace std;


#define int long long
#define ff first 
#define ss second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back



void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n);
    for(auto &i : a) cin >> i;
    for(auto &i : b) cin >> i;
    sort(all(a));
    sort(all(b));
    for(int i = 0; i <= n; i++) {
        int k = 0;
        int ans = 0;
        for(int j = 0; j < n; j++) {
            if(k == i) k++;
            ans = max(ans, max(0LL, a[k++] - b[j]));
            // cout << a[k] << " " << b[j] << "\n";
        }
        // cout << "\n";
        cout << ans << " ";
    }
}   


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


    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...