Submission #43583

#TimeUsernameProblemLanguageResultExecution timeMemory
43583RezwanArefin01Bali Sculptures (APIO15_sculpture)C++14
16 / 100
1052 ms20336 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; unordered_map<int, ll> dp[110][110]; int a[110], p[110], n; ll f(int i, int k, int o) { if(k > i) return 1e18; if(k == 1) return p[i] | o; if(dp[i][k].count(o)) return dp[i][k][o]; ll ret = 1e18; int sum = a[i]; for(int j = i - 1; j >= 1; j--) { ret = min(ret, f(j, k - 1, sum | o) | sum | o); sum += a[j]; } return dp[i][k][o] = ret; } int main(int argc, char const *argv[]) { #ifdef LOCAL_TESTING freopen("in", "r", stdin); #endif int n, l, r; cin >> n >> l >> r; for(int i = 1; i <= n; i++) { cin >> a[i]; p[i] = p[i - 1] + a[i]; } ll ans = 1e18;; for(int i = l; i <= r; i++) { ans = min(ans, f(n, i, 0)); } cout << ans << endl; }
#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...