이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int nax = 2001;
const int INF = 1e9;
int n, a, b;
long long ans;
int curBit;
int dp[nax];
int tree[nax];
bool good(long long S) {
for(int j=curBit; j<44; ++j) {
if((S>>j&1) && (~ans>>j&1)) return false;
}
return true;
}
int solve(int i) {
if(i>n) return 0;
int &ret = dp[i];
if(ret!=-1) return ret;
ret = INF;
long long S = 0;
for(int k=i; k<=n; ++k) {
S += tree[k];
if(good(S)) {
ret = min(ret, solve(k+1)+1);
}
}
return ret;
}
void PlayGround() {
cin>>n>>a>>b;
for(int i=1; i<=n; ++i) {
cin>>tree[i];
}
for(int i=44; i>=0; --i) {
curBit = i;
memset(dp, -1, sizeof dp);
if(solve(1)>b) ans |= 1LL<<i;
}
cout<<ans<<'\n';
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
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... |