Submission #253716

#TimeUsernameProblemLanguageResultExecution timeMemory
253716SortingJust Long Neckties (JOI20_ho_t1)C++14
0 / 100
0 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int k_N = 2e5 + 3; int n; int a[k_N], b[k_N]; int prefix[k_N], suffix[k_N]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); 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 + 1 + n + 1); sort(b + 1, b + 1 + n); for(int i = 1; i <= n; ++i) prefix[i] = max(prefix[i - 1], max(a[i] - b[i], 0)); for(int i = n + 1; i >= 2; --i) suffix[i] = max(suffix[i + 1], max(a[i] - b[i - 1], 0)); for(int i = 1; i <= n; ++i) cout << max(prefix[i - 1], suffix[i + 1]) << " "; cout << prefix[n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...