Submission #1023634

#TimeUsernameProblemLanguageResultExecution timeMemory
1023634vjudge1Just Long Neckties (JOI20_ho_t1)C++17
0 / 100
0 ms344 KiB
#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)

ho_t1.cpp: In function 'std::vector<int> calculate_minimal_strangeness(int, std::vector<int>&, std::vector<int>&)':
ho_t1.cpp:9:13: warning: unused variable 'director_tie' [-Wunused-variable]
    9 |         int director_tie = A[i];
      |             ^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...