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>
#include<fstream>
using namespace std;
ifstream fin("WINTER.inp");
ofstream fout("WINTER.out");
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
const ll mod = 1e9 + 7;
const int mxn = 2e5, mxm = 1e5;
int n;
ll ans[mxn + 1];
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
vt<pair<ll, int>>b;
vt<ll>a;
forr(i, 1, n + 2){
int x; cin >> x;
b.pb(make_pair(x, i));
}
sort(b.begin(), b.end());
forr(i, 1, n + 1){
int x; cin >> x;
a.pb(x);
}
sort(a.begin(), a.end());
multiset<ll>ms;
for(int i = 0; i < n; i++){
ms.insert(max(b[i + 1].first - a[i], (ll)0));
}
ans[b[0].se] = *ms.rbegin();
for(int i = 1; i <= n; i++){
// if choosen if i
ms.erase(ms.find(max(b[i].first - a[i - 1], (ll)0)));
ms.insert(max(b[i - 1].first - a[i - 1], (ll)0));
ans[b[i].second] = *ms.rbegin();
}
forr(i, 1, n + 2)cout << ans[i] << ' ';
return(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |