이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
struct element
{
int x, idx;
element(int _x = 0, int _idx = 0)
{
x = _x;
idx = _idx;
}
bool operator < (const element &e) const
{
return x < e.x;
}
} e[maxn];
int n, a[maxn], b[maxn], ans[maxn];
void solve()
{
cin >> n;
n ++;
for (int i = 1; i <= n; i ++)
{
cin >> a[i];
e[i] = element(a[i], i);
}
sort(e + 1, e + n + 1);
for (int i = 1; i < n; i ++)
cin >> b[i];
sort(b + 1, b + n);
multiset < int > st;
for (int i = 1; i < n; i ++)
st.insert(max(0, e[i + 1].x - b[i]));
for (int i = 1; i <= n; i ++)
{
ans[e[i].idx] = *st.rbegin();
///cout << "fine " << e[i].idx << endl;
if (i != n)
{
st.erase(st.find(max(0, e[i + 1].x - b[i])));
///cout << e[i + 1].x - b[i] << " " << e[i].x - b[i] << endl;
st.insert(max(0, e[i].x - b[i]));
}
}
for (int i = 1; i <= n; i ++)
cout << ans[i] << " ";
cout << endl;
}
int main()
{
solve();
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... |