답안 #1005132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005132 2024-06-22T07:41:44 Z PurpleCrayon Growing Vegetables is Fun 5 (JOI24_vegetables5) C++17
0 / 100
5000 ms 33020 KB
#include <bits/stdc++.h>
using namespace std;

#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int N = 3e5+10, MOD = 1e9+7;
const ll INF = 1e18+10;

void solve() {
    int n; cin >> n;
    vector<ll> a(2 * n); for (auto& x : a) cin >> x;
    vector<ll> b(n); for (auto& x : b) cin >> x;
    vector<ll> c(n); for (auto& x : c) cin >> x;

    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll ans = INF;
    for (int i = 0; i <= n; i++) {
        vector<ll> one, two;
        for (int rep = 0; rep < n; rep++) {
            one.push_back(a[(i + rep) % (2 * n)]);
        }

        for (int rep = 1; rep <= n; rep++) {
            two.push_back(a[(i - rep + 2 * n) % (2 * n)]);
        }

        sort(one.begin(), one.end());
        sort(two.begin(), two.end());
        ll cur = 0;
        for (int j = 0; j < n; j++) {
            cur = max(cur, abs(one[j] - b[j]));
            cur = max(cur, abs(two[j] - c[j]));
        }
        ans = min(ans, cur);
    }

    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int T = 1;
    // cin >> T;
    while (T--) solve();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5007 ms 33020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -