Submission #131122

#TimeUsernameProblemLanguageResultExecution timeMemory
131122mlyean00Bali Sculptures (APIO15_sculpture)C++14
16 / 100
6 ms1272 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; vector<int> y(n); for (int i = 0; i < n; ++i) { cin >> y[i]; } vector<int> pref(n + 1, 0); partial_sum(y.begin(), y.end(), pref.begin() + 1); bool dp[b + 1][n + 1][1 << 9]; memset(dp, 0, sizeof(dp)); dp[0][0][0] = true; for (int i = 0; i < b; ++i) { for (int j = 0; j <= n; ++j) { for (int k = 0; k < 1 << 9; ++k) { if (!dp[i][j][k]) continue; for (int h = j + 1; h <= n; ++h) { dp[i + 1][h][k | (pref[h] - pref[j])] = true; } } } } int ans = INT_MAX; for (int i = a; i <= b; ++i) { for (int k = 0; k < 1 << 9; ++k) { if (!dp[i][n][k]) continue; ans = min(ans, k); } } 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...