제출 #1333292

#제출 시각아이디문제언어결과실행 시간메모리
1333292patgraGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++20
30 / 100
5091 ms18668 KiB
#include <bits/stdc++.h>

#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))

constexpr bool dbg = 1;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl

#define int long long
#define ld long double
#define pb push_back
#define rg ranges

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(2 * n), b(n), c(n);
    rep(i, 0, 2 * n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    rg::sort(b);
    rg::sort(c);
    int ans = 2e9;
    rep(st, 0, n) {
        vector<int> a1, a2;
        rep(i, 0, 2 * n) ((i < st || a2.size() == n) ? a1 : a2).pb(a[i]);
        rg::sort(a1);
        rg::sort(a2);
        int my = 0;
        rep(i, 0, n) my = max(my, abs(b[i] - a1[i]));
        rep(i, 0, n) my = max(my, abs(c[i] - a2[i]));
        ans = min(ans, my);
        my = 0;
        rep(i, 0, n) my = max(my, abs(b[i] - a2[i]));
        rep(i, 0, n) my = max(my, abs(c[i] - a1[i]));
        ans = min(ans, my);
    }
    cout << ans << '\n';
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...