이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double doublel;
#define f first
#define s second
const int N = 3000 + 100;
const int sq = 200;
const ll mod = 1e9 + 7;
const ll inf = 1e16;
int dp[N];
ll y[N];
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n, a, b;
cin >> n >> a >> b;
for(int i = 0; i < n; i++)
cin >> y[i];
ll ans = (1ll << 42)-1;
//cout << ans << endl;
for(int i = 41; i >= 0; i--)
{
ans ^= (1ll << i);
//cout << ans << endl;
for(int j = 0; j < n; j++)
{
dp[j] = b+1;
ll sum = y[j];
for(int k = j-1; k >= 0; k--)
{
if((ans | sum) == ans)
{
dp[j] = min(dp[j], 1 + dp[k]);
}
sum += y[k];
}
if((ans | sum) == ans)
dp[j] = 1;
}
if(dp[n-1] > b)
ans ^= (1ll << i);
}
cout << ans << endl;
return 0;
}
# | 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... |