Submission #1223628

#TimeUsernameProblemLanguageResultExecution timeMemory
1223628nataliaaJust Long Neckties (JOI20_ho_t1)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h> using namespace std; void test_case() { int n; cin >> n; int a[n+1], b[n],pre[n+1] = {}, suf[n+2] = {}; for(int i = 0; i<n+1; i++) cin >> a[i]; for(int i = 0; i < n; i++) cin >> b[i]; sort(a, a+n+1); sort(b, b+n); pre[0] = max(0, a[0]-b[0]); for(int i = 1; i < n ; i++) { pre[i] = max(pre[i-1], max(a[i]-b[i], 0)); } pre[n] = pre[n-1]; suf[n+1] = max(0, a[n]-b[n-1]); suf[n] = suf[n]; for(int i = n-1; i >= 0 ; i--) { suf[i] = max(suf[i+1], max(a[i+1]-b[i], 0)); } cout <<suf[0]<<" "; for(int i = 1; i <=n; i++) { cout << max(pre[i-1], suf[i])<<" "; } } signed main() { int t; t=1; while(t--) test_case(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...