This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> t1(n + 1);
vector<int> t2(n);
vector<int> p;
vector<int> t;
for(int i = 0; i < n + 1; i++)
{
cin >> t1[i];
}
vector<int> z = t1;
for (int i = 0; i < n; i++)
{
cin >> t2[i];
}
sort(t1.begin(), t1.end());
sort(t2.begin(), t2.end());
int m = 0;
for (int i = 0; i < n; i++)
{
if (t1[i] - t2[i] > m)
{
m = t1[i] - t2[i];
}
p.push_back(m);
}
m = 0;
for (int i = n; i > 0; i--)
{
if (t1[i] - t2[i - 1] > m)
{
m = t1[i] - t2[i - 1];
}
t.push_back(m);
}
reverse(t.begin(), t.end());
map<int, int> wyn;
wyn[t1[0]] = t[0];
for (int i = 0; i < n - 1; i++)
{
wyn[t1[i + 1]] = max(p[i], t[i + 1]);
}
wyn[t1[n]] = p[p.size() - 1];
for (int i : z) {
cout << wyn[i] << " ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |