이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mod 1000000007
#define int long long
// https://www.youtube.com/watch?v=t5GDacP_2pQ
using namespace std;
int pow (int a, int b)
{
int rez = 1;
while (b)
{
if (b&1)
rez = (rez * a) % mod;
a = (a * a) % mod;
b>>=1;
}
return rez;
}
pair <int, int> a[200010];
int b[200010], n;
int ans[200010];
int st[200010];
int dr[200010];
void solve ()
{
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)
st[i] = max(st[i-1], max(0LL, a[i].first - b[i]));
for (int i = n;i>=1;--i)
dr[i] = max(dr[i+1], max(0LL, a[i+1].first - b[i]));
for (int i = n + 1;i>=1;--i)
ans[a[i].second] = max(dr[i], st[i-1]);
for (int i = 1;i<=n+1;++i)
cout << ans[i] << ' ';
cout << '\n';
}
main ()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while (t--)
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
45 | main ()
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |