제출 #1223646

#제출 시각아이디문제언어결과실행 시간메모리
1223646nataliaaJust 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); for (int i = 0; i < n; i++) { pre[i+1] = max(pre[i], max(0, a[i] - b[i])); } for (int i = n - 1; i >= 0; i--) { suf[i] = max(suf[i + 1], max(0, a[i + 1] - b[i])); } for (int i = 0; i <= n; i++) { cout << max(pre[i], suf[i]) << " "; } } signed main() { int t = 1; while (t--) test_case(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...