Submission #982211

#TimeUsernameProblemLanguageResultExecution timeMemory
982211NeroZeinGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++17
30 / 100
5040 ms17116 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n * 2); vector<int> b(n), c(n); for (int i = 0; i < n * 2; ++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 = INT_MAX; for (int rep = 0; rep < 2; ++rep) { for (int f = 0; f <= n; ++f) { vector<int> v1, v2; for (int i = 0; i < n * 2; ++i) { if (i >= f && i < f + n) { v1.push_back(a[i]); } else { v2.push_back(a[i]); } } int res = 0; sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); for (int i = 0; i < n; ++i) { res = max(res, abs(v1[i] - b[i])); res = max(res, abs(v2[i] - c[i])); } ans = min(ans, res); } swap(b, c); } cout << ans << '\n'; return 0; }
#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...