이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |