Submission #1110236

#TimeUsernameProblemLanguageResultExecution timeMemory
1110236vjudge1Growing Vegetables is Fun 5 (JOI24_vegetables5)C++17
4 / 100
5060 ms592 KiB
#include<bits/stdc++.h> #define INF 1e18 #define fi first #define se second #define FOR(i, k, n) for(ll i = k; i <= n; i++) #define FOR1(i, k, n) for(ll i = k; i >= n; i--) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define vi vector<int> #define pii pair<int, int> #define vii vector<pii> #define ll long long #define vll vector<ll> #define pll pair<ll, ll> #define re return 0 #define mii map<int, int> #define input "BESIEGE.inp" #define output "BESIEGE.out" #define rf freopen(input, "r", stdin); freopen(output, "w", stdout) using namespace std; const int maxn = 5e4 + 5; const int mod = 1e9 + 7; const int base = 998244353; void add(int &a, int b) { a += b; if(a >= mod) a -= mod; if(a < 0) a += mod; } int n, a[15], b[15], c[15], d[15]; bool vis[15]; int ans = 1e9; void inkq() { int nho = 0, lon = 0; bool ok = 0; FOR(i, 1, n * 2) { if(nho >= n || lon >= n) { ok = 1; break; } if(d[i] <= n) { nho++; lon = 0; } else { lon++; nho = 0; } } if(!ok) return; int maxx = 0; FOR(i, 1, n * 2) { int id = d[i]; if(id > n) { maxx = max(maxx, abs(a[i] - c[id - n])); } else { maxx = max(maxx, abs(a[i] - b[id])); } } ans = min(ans, maxx); } void try2(int i) { FOR(j, 1, 2 * n) if(!vis[j]) { d[i] = j; vis[j] = 1; if(i == n * 2) inkq(); else try2(i + 1); vis[j] = 0; } } int main() { fastio; cin >> n; FOR(i, 1, n * 2) cin >> a[i]; FOR(i, 1, n) cin >> b[i]; FOR(i, 1, n) cin >> c[i]; try2(1); cout << ans; re; }
#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...