Submission #227406

#TimeUsernameProblemLanguageResultExecution timeMemory
227406shafinalamBali Sculptures (APIO15_sculpture)C++14
21 / 100
25 ms32000 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mxn = 2005; ll n, A, B; ll arr[mxn]; ll pre[mxn]; ll dp[mxn][mxn]; ll last = pow(2,60); ll solve(int pos, int k) { if(pos>n) { if(k>=A && k<=B) return 0; return last; } if(dp[pos][k]!=-1) return dp[pos][k]; ll ret = last; //cout << ret << '\n'; for(int i = pos; i <= n; i++) { ret = min(ret, solve(i+1, k+1)|(pre[i]-pre[pos-1])); } //cout << ret << '\n'; return dp[pos][k] = ret; } int main() { //cout << last << '\n'; cin >> n >> A >> B; for(int i = 1; i <= n; i++) cin >> arr[i]; for(int i = 1; i <= n; i++) pre[i] = pre[i-1]+arr[i]; memset(dp, -1, sizeof dp); ll ans = solve(1, 0); cout << ans << '\n'; return 0; }
#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...