Submission #706616

#TimeUsernameProblemLanguageResultExecution timeMemory
706616Dan4LifeJust Long Neckties (JOI20_ho_t1)C++17
9 / 100
1080 ms15824 KiB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
#define int long long
const int LINF = (int)2e18;
const int mxN = (int)2e5+10;
int n, a[mxN], b[mxN];

void solve(){
    cin >> n; multiset<int> S;
    for(int i = 1; i <= n+1; i++) cin >> a[i], S.insert(a[i]);
    for(int i = 1; i <= n; i++) cin >> b[i];
    sort(b+1,b+n+1);
    for(int i = 1; i <= n+1; i++){
        S.erase(S.find(a[i]));
        auto itr = S.begin(); int ans = 0;
        for(int j = 1; j <= n; j++) ans = max(ans, *itr-b[j]), itr++;
        cout<< ans << " ";
        S.insert(a[i]);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
	int t = 1; //cin >> t;
    while(t--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...