#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <vector>
#include <deque>
#include <climits>
#define scanf scanf_s
#define mk make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 2010;
ll min2(ll v1, ll v2) { if (v1 == -1)return v2; if (v2 == -1)return v1; return min(v1, v2); }
int dp[110][1 << 20],a[110],n,av,bv;
int main() {
memset(dp, -1, sizeof(dp));
dp[0][0] = 0;
cin >> n >> av >> bv;
for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; }
for (int i = 0; i < n; i++) {
for (int i2 = i + 1; i2 <= n; i2++) {
int v1 = a[i2] - a[i];
for (int s = 0; s < (1 << 20); s++) {
if (dp[i][s] == -1)continue;
dp[i2][s | v1] = min2(dp[i2][s | v1], dp[i][s] + 1);
}
}
}
for (int s = 0; s < (1 << 20); s++) { if (dp[n][s] != -1 && dp[n][s] <= bv) { cout << s << endl; break; } }
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
194 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
214 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
204 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
228 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
201 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |