Submission #1314637

#TimeUsernameProblemLanguageResultExecution timeMemory
1314637pvproGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++20
0 / 100
5092 ms18700 KiB
#ifndef LOCAL #pragma GCC Optimize("O3,Ofast,unroll-loops") #pragma GCC Target("bmi,bmi2,avx,avx2") #endif #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define int ll #define f first #define s second #define mp make_pair #define pb push_back #define pii pair<int, int> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin() (x).rend() #ifndef LOCAL #define endl "\n" #endif mt19937 rnd(11); vector<int> solve(vector<int> &a, vector<int> &b) { int n = a.size() / 2; vector<int> ans(n); for (int i = 0; i < n; ++i) { vector<int> now; for (int j = 0; j < n; ++j) { now.pb(a[i + j]); } sort(all(now)); for (int i = 0; i < n; ++i) { ans[i] = max(ans[i], abs(now[i] - b[i])); } } return ans; } void solve() { int n; cin >> n; vector<int> a(n * 2); for (auto &x : a) { cin >> x; } vector<int> b(n); for (auto &x : b) { cin >> x; } vector<int> c(n); for (auto &x : c) { cin >> x; } sort(all(b)); sort(all(c)); vector<int> ansB = solve(a, b); vector<int> ansC = solve(a, c); vector<int> a_(a.size()); for (int i = 0; i < a.size(); ++i) { a_[i] = a[(i + n) % a.size()]; } vector<int> ansB_ = solve(a_, c); vector<int> ansC_ = solve(a_, b); int ans = 1e18; for (int i = 0; i < n; ++i) { ans = min(ans, max(ansB[i], ansB_[i])); ans = min(ans, max(ansC[i], ansC_[i])); } cout << ans << endl; } signed main() { #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #else ios::sync_with_stdio(false); cin.tie(0); #endif 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...