제출 #1314641

#제출 시각아이디문제언어결과실행 시간메모리
1314641pvproGrowing Vegetables is Fun 5 (JOI24_vegetables5)C++20
9 / 100
5092 ms23392 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 x) { int n = a.size() / 2; vector<int> ans(n, 1); 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 j = 0; j < n; ++j) { if (abs(now[j] - b[j]) > x) { ans[i] = 0; break; } } } 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> a_(a.size()); for (int i = 0; i < a.size(); ++i) { a_[i] = a[(i + n) % a.size()]; } int l = -1, r = 1e9 + 1; while (r - l > 1) { int m = (l + r) / 2; vector<int> ansB = solve(a, b, m); vector<int> ansC = solve(a, c, m); vector<int> ansB_ = solve(a_, c, m); vector<int> ansC_ = solve(a_, b, m); bool ok = false; for (int i = 0; i < n; ++i) { if (ansB[i] && ansB_[i]) { ok = true; break; } if (ansC[i] && ansC_[i]) { ok = true; break; } } if (ok) { r = m; } else { l = m; } } cout << r << 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...