이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vector<pair<LL, int> > A(N + 1);
vector<LL> B(N);
for (int i = 0; i <= N; 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());
multiset<LL> vals;
for (int i = 0; i < N; i++) {
// After - Before;
vals.insert(max(A[i + 1].first - B[i], 0LL));
}
vector<LL> ans(N + 1);
for (int i = 0; i <= N; i++) {
if (i) {
vals.erase(vals.find(max(A[i].first - B[i - 1], 0LL)));
vals.insert(max(A[i - 1].first - B[i - 1], 0LL));
}
ans[A[i].second] = *vals.rbegin();
}
for (int i = 0; i <= N; i++) {
if (i) cout << ' ';
cout << ans[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... |