이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int main() {
cin >> n;
vector<pair<int, int>> ties(n + 1);
vector<int> current(n);
for (int i = 0; i <= n; i++) {
cin >> ties[i].first;
ties[i].second = i;
}
for (int i = 0; i < n; i++) {
cin >> current[i];
}
sort(ties.begin(), ties.end());
sort(current.begin(), current.end());
vector<int> start = {0};
vector<int> shifted = {0};
int temp1 = 0;
int temp2 = 0;
for (int i = 0; i < n; i++) {
temp1 = max(temp1, ties[i].first - current[i]);
start.push_back(temp1);
}
start.push_back(max(temp1, ties[n].first - current[n - 1]));
for (int i = n - 1; i >= 0; i--) {
temp2 = max(temp2, ties[i + 1].first - current[i]);
shifted.push_back(temp2);
}
reverse(shifted.begin(), shifted.end());
//indexing issue below?
vector<int> answers(n + 1);
for (int i = 0; i <= n; i++) {
answers[ties[i].second] = max(start[i], shifted[i]);
}
for (auto i: answers) {
cout << 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... |