이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("Ofast")
bitset<2001> dp[2003];
ll sm[2003];
bitset<2001> mv[2003];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,a,b;
cin >> n >> a >> b;
for (ll i = 1; i<=n; i++){
cin >> sm[i];
sm[i]+=sm[i-1];
}
ll ans=((ll)1<<41)-1;
dp[0][0]=1;
for (ll u = 40; u>=0; u--){
ll cur=ans-((ll)1<<u);
for (ll i = 1; i<=n; i++){
for (ll j = 0; j<i; j++){
if ((cur|(sm[i]-sm[j]))==cur)mv[i][j]=1;
else mv[i][j]=0;
}
for (ll j = i; j<=n; j++)mv[i][j]=0;
}
for (ll i = 1; i<=b; i++){
for (ll j = 1; j<=n; j++){
if ((dp[i-1]&mv[j]).any())dp[i][j]=1;
else dp[i][j]=0;
}
}
for (ll i = a; i<=b; i++){
if (dp[i][n]){
ans=cur;
break;
}
}
}
cout << ans << '\n';
}
# | 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... |