이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
pair<int, int> a[200002];
int b[200001], ans[200002], pref[200002], suff[200002];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
FOR(i, 1, n + 2) {
cin >> a[i].first;
a[i].second = i;
}
FOR(i, 1, n + 1) cin >> b[i];
sort(a + 1, a + n + 2);
sort(b + 1, b + n + 1);
FOR(i, 1, n + 1) pref[i] = max(pref[i - 1], max(a[i].first - b[i], 0));
FOR(i, 1, n + 1) suff[i] = max(suff[i - 1], max(a[n + 2 - i].first - b[n + 1 - i], 0));
FOR(i, 1, n + 2) ans[a[i].second] = max(pref[i - 1], suff[n + 1 - i]);
FOR(i, 1, n + 2) cout << ans[i] << ' ';
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... |