Submission #43582

#TimeUsernameProblemLanguageResultExecution timeMemory
43582RezwanArefin01Bali Sculptures (APIO15_sculpture)C++14
16 / 100
1060 ms16132 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; map<int, int> dp[110][110]; int a[110], p[110], n; int f(int i, int k, int o) { if(k > i) return 1 << 30; if(k == 1) return p[i] | o; if(dp[i][k].count(o)) return dp[i][k][o]; int &ret = dp[i][k][o] = 1 << 30; 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 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]; } int ans = 2e9; 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...