이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
main()
{
int n; cin >> n;
vector <int> a(n + 1);
for(int i = 0; i <= n; i++) cin >> a[i];
vector <int> a0 = a;
vector <int> b(n);
for(int i = 0; i < n; i++) cin >> b[i];
sort(a.begin(), a.end()); sort(b.begin(), b.end());
map <int, int> idx;
for(int i = 0; i <= n; i++) idx[a[i]] = i;
vector <int> dpl(n + 1), dpr(n + 1);
for(int i = 1; i <= n; i++)
{
dpl[i] = max(0, a[i - 1] - b[i - 1]);
dpr[i - 1] = max(0, a[i] - b[i - 1]);
}
for(int i = 1; i <= n; i++) dpl[i] = max(dpl[i], dpl[i - 1]);
for(int i = n; i >= 1; i--) dpr[i - 1] = max(dpr[i - 1], dpr[i]);
for(int i = 0; i <= n; i++)
{
if(i != 0) cout << " ";
int trace = idx[a0[i]];
cout << max(dpl[trace], dpr[trace]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | 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... |