이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
vector<int> b, ans;
vector<pair<int, int>> a;
int main() {
cin >> n;
a.resize(n + 1), b.resize(n);
for (int i = 0; i < n + 1; i++) {
cin >> a[i].first;
a[i].second = i;
}
for (int i = 0; i < n; i++) {
cin >> b[i];
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
ans.resize(n + 1);
int oddity = 0;
for (int i = 0; i < n; i++) {
oddity = max(oddity, max(a[i].first - b[i], 0));
}
ans[a[n].second] = oddity;
for (int i = n; i >= 1; i--) {
oddity = max(oddity, max(a[i].first - b[i - 1], 0));
ans[a[i - 1].second] = oddity;
}
for (int i = 0; i < n + 1; i++) {
cout << ans[i] << ' ';
}
cout << '\n';
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... |