#include<iostream>
#include<vector>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SZ = 3000, INF = 1e9;
vector<ll> vec;
ll n, a, b;
ll dp[SZ];
bitset<SZ> dp2[SZ];
ll sol(bool fl) {
ll curMsk = (1ll << 37) - 1;
for (ll bt = 36; bt >= 0; bt--) {
ll msk = curMsk ^ (1ll << bt);
bool k = 0;
if (!fl) {
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) dp2[i][j] = 0;
}
dp2[0][0] = 1;
for (int i = 0; i < n; i++) {
ll s = 0;
for (int j = i; j >= 0; j--) {
s += vec[j];
if ((msk | s) == msk) {
dp2[i + 1] |= (dp2[j] << 1);
}
}
}
for (int i = a; i <= b; i++) {
if (dp2[n][i]) {
k = 1;
}
}
}
else {
dp[0] = 0;
for (int i = 0; i <= n; i++) dp[i] = INF;
for (int i = 0; i < n; i++) {
ll s = 0;
for (int j = i; j >= 0; j--) {
s += vec[j];
if ((msk | s) == msk) {
dp[i + 1] = min(dp[i + 1], dp[j] + 1);
}
}
}
if (dp[n] <= b) k = 1;
}
if (k) {
curMsk = msk;
}
}
return curMsk;
}
int main() {
fastInp;
cin >> n >> a >> b;
vec.resize(n);
for (auto &cur : vec) cin >> cur;
if (a == 1) {
cout << sol(1);
}
else {
cout << sol(0);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |