이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=105;
ll n, a, b, x, vl[nx], dp[nx][nx], msk, p[40], m;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>a>>b;
p[0]=1;
for (int i=1; i<40; i++) p[i]=p[i-1]*2;
m=p[39]-1;
for (int i=1; i<=n; i++) cin>>vl[i];
dp[0][0]=1;
for (int x=38; x>=0; x--)
{
m-=p[x];
for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) dp[i][j]=0;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=n; j++)
{
msk=vl[i];
for (int k=i-1; k>=0; k--)
{
if ((msk|m)==m&&dp[k][j-1]) dp[i][j]|=1;
msk+=vl[k];
}
}
}
bool can=0;
for (int j=a; j<=b; j++) can|=dp[n][j];
if (!can) m+=p[x];
}
cout<<m;
}
/*
6 1 3
8 1 2 1 5 4
01011
01101
01111
10101
274877906943
*/
# | 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... |