이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define debug(x) cout << #x << "= " << x << ", "
#define ll long long
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define Sz(x) (int) x.size()
#define int long long
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 2e3 + 10 , maxl = 50;
int n , ar[maxn] , a , b , res , ps[maxn];
int dp[maxn];
bool find_ans(int mask)
{
for(int i = 1 ; i <= n ; i++)
dp[i] = n + 1;
dp[0] = 0;
for(int i = 1 ; i <= n ; i++)
{
for(int k = 0 ; k < i ; k++)
{
int tmp = ps[i] - ps[k];
if((tmp & mask) == tmp)
dp[i] = min(dp[i] , dp[k] + 1);
}
}
bool flg = false;
if(dp[n] <= b)
flg = true;
return flg;
}
void solve()
{
for(int bit = maxl ; bit > -1 ; bit--)
{
int tmp = res;
tmp |= ((1LL << (bit)) - 1);
if(!find_ans(tmp))
res |= (1LL << bit);
}
}
int32_t main()
{
fast;
cin >> n >> a >> b;
for(int i = 1 ; i <= n ; i++)
{
cin >> ar[i];
ps[i] = ps[i - 1] + ar[i];
}
solve();
cout << res << 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... |