Submission #742318

#TimeUsernameProblemLanguageResultExecution timeMemory
742318viwlesxqBali Sculptures (APIO15_sculpture)C++17
16 / 100
15 ms796 KiB
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; typedef string str; const int N = 101; const int R = 21; const int Y = 501; const ll inf = 1e18; ll y[N], pref[N]; bool dp[N][R][Y]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); 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 = 1; i <= n; ++i) { dp[i][1][pref[i]] = true; } for (int k = 2; k <= b; ++k) { for (int i = 1; i <= n; ++i) { for (int j = i - 1; j >= 1; --j) { for (int x = 0; x < Y; ++x) { if (dp[j][k - 1][x]) { dp[i][k][x | (pref[i] - pref[j])] = true; } } } } } ll ans = inf; for (int k = a; k <= b; ++k) { for (int x = 0; x < Y; ++x) { if (dp[n][k][x]) { ans = min(ans, (ll)x); } } } cout << ans; }
#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...