Submission #1005134

#TimeUsernameProblemLanguageResultExecution timeMemory
1005134PurpleCrayonGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++17
30 / 100
5043 ms19396 KiB
#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 tt = 0; tt < 2; tt++) { 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); } swap(b, c); } cout << ans << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); int T = 1; // cin >> T; while (T--) solve(); }
#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...