#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define sp " "
#define debug(x) cout << #x << " => " << x << "\n"
const int mod = 998244353;
const ld err = 1e-6;
int n, a, b;
int arr[2005];
int sum(int l, int r){
return arr[r] - arr[l - 1];
}
void solve_1(){
int banned = 0;
int ans = 0;
for(int bit = 5; bit >= 0; bit--){
// Check if we can erase this bit
banned |= (1ll << bit);
int dp[2005];
fill(dp + 1, dp + n + 1, 1e18 + 7);
dp[0] = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= i; j++){
if((sum(j, i) & banned) == 0)
dp[i] = min(dp[i], dp[j - 1] + 1);
}
}
if(dp[n] > b){
ans |= (1ll << bit);
banned ^= (1ll << bit);
}
}
cout << ans << "\n";
}
void solve_2(){
}
void input(){
cin >> n >> a >> b;
for(int i = 1; i <= n; i++){
cin >> arr[i];
arr[i] += arr[i - 1];
}
if(a == 1)
solve_1();
else solve_2();
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
input();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
292 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
316 KB |
Output is correct |
6 |
Correct |
0 ms |
320 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
312 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |