Submission #254874

#TimeUsernameProblemLanguageResultExecution timeMemory
254874imeimi2000Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
127 ms10872 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int n; pii A[200001]; int B[200001]; int L[200002]; int R[200002]; int ans[200001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i <= n; ++i) { cin >> A[i].first; A[i].second = i; } for (int i = 1; i <= n; ++i) cin >> B[i]; sort(A, A + (n + 1)); sort(B + 1, B + (n + 1)); for (int i = 1; i <= n; ++i) L[i] = max(L[i - 1], A[i - 1].first - B[i]); for (int i = n; i > 0; --i) R[i] = max(R[i + 1], A[i].first - B[i]); for (int i = 0; i <= n; ++i) ans[A[i].second] = max(L[i], R[i + 1]); for (int i = 0; i <= n; ++i) printf("%d%c", ans[i], "\n "[i < n]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...