이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a,b,x[2005];
ll res = 0;
bool dp[2005][2005];
int main(){
cin >> n >> a >> b;
for(int i=1;i<=n;i++)
cin >> x[i];
for(int bit=40;bit>=0;bit--){
memset(dp,0,sizeof(dp));
dp[0][0] = 1;
for(int i=0;i<=n;i++){
for(int j=0;j<=i;j++){
if (!dp[i][j]) continue;
ll sum = 0;
for(int k=i+1;k<=n;k++){
sum += x[k];
if (((sum>>bit)|(res>>bit)) == (res>>bit))
dp[k][j+1] = 1;
}
}
}
bool ok = 0;
for(int j=a;j<=b;j++)
if (dp[n][j]) ok = 1;
if (!ok) res += (1<<bit);
}
cout << res;
}
# | 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... |