이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//I wrote this code 4 u <3
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
signed main(int32_t argc, char *argv[]) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<pair<int, int>> a(n + 1);
for (int i = 0; i <= n; ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin(), a.end());
vector<int> b(n);
for (int i = 0; i < n; ++i) {
cin >> b[i];
}
sort(b.begin(), b.end());
vector<int> pref(n + 2, 0), suf(n + 2, 0);
for (int i = 0; i < n; ++i) {
pref[i + 1] = max(pref[i], a[i].first - b[i]);
}
for (int i = n - 1; i > -1; --i) {
suf[i] = max(suf[i + 1], a[i + 1].first - b[i]);
}
vector<int> ans(n + 1);
for (int i = 0; i <= n; ++i) {
ans[a[i].second] = max(pref[i], suf[i]);
}
for (auto x : ans) {
cout << x << ' ';
}
}
/*
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |