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;
typedef long long ll;
typedef vector<int> vi;
typedef vector <ll> vll;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector <pii> vpii;
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define endl "\n"
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vpii a(n+1);
for(int i = 0; i < n+1; i++) {
cin >> a[i].first;
a[i].second = i;
}
vi b(n);
for(int i = 0; i < n; i++) {
cin >> b[i];
}
sort(all(a));
sort(all(b));
vector<int> ans(n+1);
int mx = 0;
for(int i = 0; i < n; i++) {
mx = max(mx, max(0, a[i].first-b[i]));
}
ans[a[a.size()-1].second] = mx;
for(int i = n-1; i >=0; i--) {
mx = max(mx, max(0, a[i+1].first-b[i]));
ans[a[i].second] = mx;
}
for(int a: ans) {
cout << a << " ";
}
cout << endl;
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... |