Submission #388810

#TimeUsernameProblemLanguageResultExecution timeMemory
388810milleniumEeeeBali Sculptures (APIO15_sculpture)C++17
0 / 100
11 ms16048 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pii pair<int, int> #define pb push_back #define szof(s) (int)s.size() #define all(s) s.begin(), s.end() #define fastInp ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; const int MAXN = 2005; int y[MAXN]; int dp[MAXN][MAXN]; int pref[MAXN]; int get_sum(int l, int r) { return pref[r] - pref[l - 1]; } const int INF = INT_MAX; signed main() { fastInp; int n, a, b; cin >> n >> a >> b; for (int i = 1; i <= n; i++) { cin >> y[i]; pref[i] = pref[i - 1] + y[i]; } for (int i = 0; i < MAXN; i++) { for (int j = 0; j < MAXN; j++) { dp[i][j] = INF; } } dp[0][0] = 0; for (int gr = 1; gr <= b; gr++) { for (int i = gr; i <= n; i++) { for (int last = 0; last < i; last++) { if (dp[last][gr - 1] != INF) { dp[i][gr] = min(dp[i][gr], dp[last][gr - 1] | get_sum(last + 1, i)); } } } } int ans = INT_MAX; for (int gr = a; gr <= b; gr++) { ans = min(ans, dp[n][gr]); } cout << ans << endl; } /* 6 1 3 8 1 2 1 5 4 */
#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...