Submission #123875

#TimeUsernameProblemLanguageResultExecution timeMemory
123875mlyean00Bali Sculptures (APIO15_sculpture)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, a, b; cin >> n >> a >> b; vector<ll> y(n); for (int i = 0; i < n; ++i) { cin >> y[i]; } vector<ll> y_pref(n + 1, 0); partial_sum(y.begin(), y.end(), y_pref.begin() + 1); vector<vector<ll>> dp(b + 1, vector<ll>(n + 1, LLONG_MAX)); dp[0][0] = 0; for (int i = 1; i <= b; ++i) { for (int j = 1; j <= n; ++j) { for (int k = 0; k < j; ++k) { if (dp[i - 1][k] == LLONG_MAX) continue; dp[i][j] = min(dp[i][j], dp[i - 1][k] | (y_pref[j] - y_pref[k])); } } } ll ans = LLONG_MAX; for (int i = a; i <= b; ++i) { ans = min(ans, dp[i][n]); } cout << ans << endl; 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...