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<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define int long long
using namespace std;
//想5 實作15
signed main() {
int n;
cin >> n;
vector<pair<int, int> >a(n+1);
vector<int> b(n);
vector<int>ans(n);
for (int i = 0 ; i < n+1 ; i++) {
cin >> a[i].first;
a[i].second = i;
}
for (auto &i : b) cin >> i;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for (int i = 0 ; i < n ; i++) {
ans[i] = max(a[i+1].first - b[i], 0ll);
}
vector<int>out(n+1);
for (int i = 0 ; i < n+1 ; i++) {
out[a[i].second] = (*max_element(ans.begin(), ans.end()));//.first;// << " ";
if (i == n) break;
ans[i] = max(a[i].first - b[i], 0ll);
}
for (int i = 0 ; i < n+1 ; i++) {
cout << out[i] << " ";
}
cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |