Submission #1135845

#TimeUsernameProblemLanguageResultExecution timeMemory
1135845SoulKnightJust Long Neckties (JOI20_ho_t1)C++20
0 / 100
0 ms320 KiB
#include "bits/stdc++.h" using namespace std; // #define int long long #define double long double #define ln '\n' int a[200005], b[200005]; int pfx[200005], sfx[200005]; void solve(){ int n; cin >> n; for (int i = 1; i <= n+1; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; sort(a+1, a+n+2); sort(b+1, b+n+1); pfx[0] = 0; for (int i = 1; i <= n; i++){ int cur = max(a[i] - b[i], 0); pfx[i] = max(pfx[i-1], cur); } sfx[n+1] = 0; for (int i = n; i >= 1; i--){ int cur = max(a[i+1] - b[i], 0); sfx[i] = max(sfx[i+1], cur); } for (int i = 1; i <= n+1; i++){ cout << max(pfx[i-1], sfx[i]) << ' '; } cout << ln; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); solve(); // int TT; cin >> TT; // while (TT--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...