Submission #839234

#TimeUsernameProblemLanguageResultExecution timeMemory
839234Ivo_12Bali Sculptures (APIO15_sculpture)C++98
37 / 100
39 ms15888 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll n; ll arr[2010]; ll memo[100][100][410]; ll a, b; const ll inf = 1e18; ll rek( int p, int k, int o ) { if(p==n) { if(k>=a&&k<=b) return o; return inf; } if(memo[p][k][o]) return memo[p][k][o]; ll sum = 0, ans = inf; for(int i = p; i < n; i++) { sum += arr[i]; ans = min(rek(i+1, k+1, o|sum), ans); } memo[p][k][o] = ans; return ans; } int main( void ) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n >> a >> b; for(int i = 0; i < n; i++) cin >> arr[i]; cout << rek(0, 0, 0); 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...