# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106235 | abil | Bali Sculptures (APIO15_sculpture) | C++14 | 3 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)
#define pi pair < int, int >
using namespace std;
const long long INF = (int)1e18 + 7;
const int N = (int)2007;
const int mod = 1000000007;
pi dp[N][N];
int y[N];
int n, a, b;
int ans;
main(){
ans = INF;
cin >> n >> a >> b;
for (int i = 1; i <= n; i++){
scanf("%lld", &y[i]);
}
for (int i = 1; i <= n; i++){
for (int j = 0; j <= n; j++){
dp[i][j] = {INF, INF};
}
}
for (int i = 1; i <= n; i++){
for (int g = 1; g <= min(i, b); g++){
if ((dp[i - 1][g].fr | (dp[i - 1][g].sc + y[i])) < ((dp[i - 1][g - 1].fr | dp[i - 1][g - 1].sc) | y[i])){
dp[i][g] = {dp[i - 1][g].fr, (dp[i - 1][g].sc + y[i])};
}
else {
dp[i][g] = { (dp[i - 1][g - 1].fr | dp[i - 1][g - 1].sc) , y[i]};
}
//cout << dp[i][g].fr << ' ' << dp[i][g].sc << ' ' << i << ' ' << g << endl;
//system("pause");
}
}
for (int g = a; g <= b; g++)
ans = min(ans, (dp[n][g].fr | dp[n][g].sc));
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |