Submission #1109856

#TimeUsernameProblemLanguageResultExecution timeMemory
1109856Rainmaker2627Bali Sculptures (APIO15_sculpture)C++17
0 / 100
2 ms456 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int inf=1e18; signed main() { cin.tie(0)->sync_with_stdio(false); int n, a, b; cin >> n >> a >> b; vector<int> pre(n+1, 0); for (int i = 1; i <= n; ++i) { cin >> pre[i]; pre[i]+=pre[i-1]; } vector<vector<int>> dp(n+1, vector<int>(b+1, inf)); for (int i = 0; i <= n; ++i) dp[i][0]=pre[i]; for (int k = 1; k <= b; ++k) { for (int i = k; i <= n; ++i) { for (int j = k-1; j < i; ++j) { dp[i][k]=min(dp[i][k], dp[j][k-1]|(pre[i]-pre[j])); } //cout << dp[i][k] << ' '; } //cout << '\n'; } //cout << '\n'; int m=inf; for (int i = a; i <= b; ++i) { m=min(m, dp[n][i]); } cout << m << '\n'; 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...