이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 110, LOG = 40;
ll ps[N], n, A, B;
bool dp[N][N];
bool good(ll vl, int k, ll res){
if(((vl | res) - res) < (1LL << k))return true;
return false;
}
bool check(int k, ll res){
dp[0][0] = true;
for(int i=1; i<=n; i++)
dp[i][0] = false;
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
dp[i][j] = false;
for(int t=i-1; t>=0; t--)
if(good(ps[i] - ps[t], k, res))
dp[i][j] |= dp[t][j - 1];
}
}
for(int i=A; i<=B; i++)
if(dp[n][i])return true;
return false;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> A >> B;
for(int i=0; i<n; i++){
int x; cin >> x;
ps[i + 1] = ps[i] + x;
}
ll res = 0;
for(int i=LOG-1; i>=0; i--){
if(!check(i, res))res += (1LL << i);
}
cout << res << endl;
}
# | 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... |