# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023634 | vjudge1 | Just Long Neckties (JOI20_ho_t1) | C++17 | 0 ms | 344 KiB |
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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> calculate_minimal_strangeness(int N, vector<int>& A, vector<int>& B) {
sort(A.begin(), A.end());
vector<int> C(N + 1);
for (int i = 0; i <= N; ++i) {
int director_tie = A[i];
vector<int> other_ties;
for (int j = 0; j <= N; ++j) {
if (j != i) other_ties.push_back(A[j]);
}
int max_strangeness = 0;
for (int b : B) {
auto it = lower_bound(other_ties.begin(), other_ties.end(), b);
int best_tie = (it == other_ties.end()) ? other_ties.back() : *it;
if (it != other_ties.begin() && (abs(*(it - 1) - b) < abs(best_tie - b))) {
best_tie = *(it - 1);
}
int strangeness = max(best_tie - b, 0);
max_strangeness = max(max_strangeness, strangeness);
}
C[i] = max_strangeness;
}
return C;
}
int main() {
int N;
cin >> N;
vector<int> A(N + 1);
for (int i = 0; i <= N; ++i) {
cin >> A[i];
}
vector<int> B(N);
for (int i = 0; i < N; ++i) {
cin >> B[i];
}
vector<int> result = calculate_minimal_strangeness(N, A, B);
for (int i = 0; i <= N; ++i) {
cout << result[i] << " ";
}
cout << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |