This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |