제출 #1221057

#제출 시각아이디문제언어결과실행 시간메모리
1221057nataliaaJust 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+1] = {};
    for(int i = 0; i<=n; 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] = max(0, a[n]-b[n-1]);
    suf[n-1] = 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...