Submission #1128976

#TimeUsernameProblemLanguageResultExecution timeMemory
1128976fzyzzz_zGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++20
30 / 100
5092 ms9548 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3e5; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(2 * n), b(n), c(n); for (int i = 0; i < 2 * n; ++i) { cin >> a[i]; } for (int i = 0; i < n; ++i) { cin >> b[i]; } for (int i = 0; i < n; ++i) { cin >> c[i]; } sort(b.begin(), b.end()); sort(c.begin(), c.end()); int ans = 1e9; for (int st = 0; st < 2 * n; ++st) { vector<int> xs, ys; for (int j = 0; j < 2 * n; ++j) { if (j < n) { xs.push_back(a[(st + j) % (2 * n)]); } else { ys.push_back(a[(st + j) % (2 * n)]); } } sort(xs.begin(), xs.end()); sort(ys.begin(), ys.end()); int mx = 0; for (int i = 0; i < n; ++i) { mx = max(mx, abs(xs[i] - b[i])); mx = max(mx, abs(ys[i] - c[i])); } ans = min(ans, mx); } 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...