Submission #227124

#TimeUsernameProblemLanguageResultExecution timeMemory
227124maruiiJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
123 ms10872 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; #define ff first #define ss second int N, B[200005], P[200005], S[200005], C[200005]; pii A[200005]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> N; for (int i = 1; i <= N + 1; ++i) { int x; cin >> x; A[i] = {x, i}; } for (int i = 1; i <= N; ++i) cin >> B[i]; sort(A + 1, A + N + 2); sort(B + 1, B + N + 1); for (int i = 1; i <= N; ++i) P[i] = max(P[i - 1], A[i].ff - B[i]); for (int i = N + 1; i > 1; --i) S[i] = max(S[i + 1], A[i].ff - B[i - 1]); for (int i = 1; i <= N + 1; ++i) C[A[i].ss] = max(P[i - 1], S[i + 1]); for (int i = 1; i <= N + 1; ++i) printf("%d ", C[i]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...