이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int Nmax = 2e5 + 5;
int dp1[Nmax], dp2[Nmax], A[Nmax], B[Nmax], ans[Nmax];
pair<int,int> ord[Nmax];
int n;
int main()
{
// freopen("input", "r", stdin);
cin.sync_with_stdio(false); cin.tie(0);
cin >> n;
int i;
for(i=1; i<=n+1; ++i) cin >> ord[i].first, ord[i].second = i;
for(i=1; i<=n; ++i) cin >> B[i];
sort(B+1, B+n+1);
sort(ord+1, ord+n+2);
for(i=1; i<=n+1; ++i) A[i] = ord[i].first;
for(i=1; i<=n; ++i)
dp1[i] = max(dp1[i-1], A[i] - B[i]);
for(i=n+1; i>=2; --i)
dp2[i] = max(dp2[i+1], A[i] - B[i-1]);
for(i=1; i<=n+1; ++i)
ans[ord[i].second] = max(dp1[i-1], dp2[i+1]);
for(i=1; 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... |