이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define sumof(x) accumulate(all(x), 0ll)
const int N=2e5+10;
int pre[N], suf[N], n, b[N], res[N];
pair<int, int> a[N];
void solve(int tc){
// cout << "Case #" << tc << ": ";
cin >> n;
for (int i=1; i<=n+1; ++i) cin >> a[i].first, a[i].second=i;
for (int i=1; i<=n; ++i) cin >> b[i];
sort(a+1, a+n+2);
sort(b+1, b+n+1);
for (int i=1; i<=n; ++i) pre[i]=max(pre[i-1], a[i].first-b[i]);
for (int i=n; i>=1; --i) suf[i]=max(suf[i+1], a[i+1].first-b[i]);
for (int i=1; i<=n+1; ++i) res[a[i].second]=max(pre[i-1], suf[i]);
for (int i=1; i<=n+1; ++i) cout << res[i] << ' ';
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int ntests=1;
// cin >> ntests;
for (int i=1; i<=ntests; ++i) solve(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... |