Submission #239162

#TimeUsernameProblemLanguageResultExecution timeMemory
239162dCodingBali Sculptures (APIO15_sculpture)C++14
0 / 100
5 ms512 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <unordered_map> #define ll long long int #define F0R(i,n) for(auto i = 0; i < (n); i++) #define FOR(i,a,b) for(auto i = (a); i <= (b); i++) #define ROF(i,a,b) for(auto i = (a); i >= (b); i--) #define pii pair<int,int> #define pll pair<ll,ll> #define vv vector #define F first #define S second #define pb push_back #define vi vector<int> using namespace std; const int MAXN = 105; int n,a,b; ll arr[MAXN],pre[MAXN]; ll dp[MAXN][MAXN]; ll f(int i,int j) { // cout << "i = " << i << " j = " << j << endl; if(dp[i][j] != -1) return dp[i][j]; if(i == 0) return dp[i][j] = 0; if(j <= 1) return dp[i][j] = pre[i]; if(j > i) return dp[i][j] = 1e9; ll res = pre[i]; FOR(k,1,i-1) res = min(res,f(k,j-1) | (pre[i]-pre[k])); return dp[i][j] = res; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> a >> b; FOR(i,1,n) cin >> arr[i]; FOR(i,1,n) pre[i] = pre[i-1]+arr[i]; memset(dp,-1,sizeof(dp)); // FOR(i,1,n) FOR(j,1,n) dp[i][j] = 1e9; // FOR(i,1,n) { // F0R(k,i) { // FOR(j,k+1,i) { // dp[i][j] = min(dp[i][j],dp[k][j-1]|(pre[i]-pre[k])); // cout << " i = " << i << " j = " << j << " k = " << k << " dp[i][j] = " << dp[i][j] << endl; // } // } // } ll ans = 1e9; // FOR(i,1,n) f(i,i); FOR(i,a,b) ans = min(ans,f(n,i)); cout << ans; // cout << endl << endl; // FOR(i,1,n) { // FOR(j,1,n) { // cout << dp[i][j] << " "; // } // cout << 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...