# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023688 | 2024-07-15T04:47:16 Z | vjudge1 | Just Long Neckties (JOI20_ho_t1) | C++17 | 0 ms | 0 KB |
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int N; cin >> N; vector<long long> A(N + 1), B(N); for (int i = 0; i <= N; ++i) { cin >> A[i]; } for (int i = 0; i < N; ++i) { cin >> B[i]; } sort(B.begin(), B.end()); vector<long long> C(N + 1, LLONG_MAX); for (int k = 0; k <= N; ++k) { long long Ak = A[k]; auto it = lower_bound(B.begin(), B.end(), Ak); if (it != B.end()) { C[k] = min(C[k], max(0LL, *it - Ak)); } if (it != B.begin()) { --it; C[k] = min(C[k], max(0LL, Ak - *it)); } } for (int k = 0; k <= N; ++k) { cout << C[k] << " "; } cout << endl; return 0; }