Submission #844356

#TimeUsernameProblemLanguageResultExecution timeMemory
844356vjudge1Holding (COCI20_holding)C++17
0 / 110
2071 ms348 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; //#define int long long #define ONLINE_JUDGE #ifndef ONLINE_JUDGE #define OPEN freopen(".in", "r", stdin); \ freopen(".out", "w", stdout); #else #define OPEN void(23); #endif void solve() { int n, l, r, k; cin >> n >> l >> r >> k; vector <int> vec(n); for(int i = 1; i <= n; i++) cin >> vec[i -1]; vector <int> perm(n); iota(perm.begin(), perm.end(), 0ll); int ans = 1e9; do { int calc = 0; for(int i = 0; i < n; i++) calc += abs(i - perm[i]); if(calc > k * 2) continue; int cev = 0; for(int i = l -1; i <= r -1; i++) cev += vec[perm[i]]; ans = min(ans, cev); } while(next_permutation(perm.begin(), perm.end())); cout << ans; return; } int32_t main() { OPEN; ios_base::sync_with_stdio(false); cin.tie(0); cout.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...