#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e3 + 5;
int n, u, v;
int a[N];
ll pre[N];
bool ck(ll a, ll b, ll c){
return (a | b) < (b | c);
}
namespace sub1{
int dp[N];
void solve(){
ll ans = 0;
for (ll i = 45; i >= 0; -- i){
ll cur = (1 << i);
for (int j = 1; j <= n; ++ j){
dp[j] = n + 1;
for (int k = j - 1; k >= 0; -- k){
if (ck(pre[j] - pre[k], ans, cur)) dp[j] = min(dp[j], dp[k] + 1);
}
}
if (dp[n] > v) ans += cur;
}
cout << ans;
}
}
namespace sub2{
void solve(){
}
}
void solve(){
cin >> n >> u >> v;
for (int i = 1; i <= n; ++ i) cin >> a[i], pre[i] = pre[i - 1] + a[i];
if (u == 1) sub1::solve();
else sub2::solve();
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |