이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,k,x,y,z;
ll a,b;
bool dp[105][105];
ll ar[105];
bool check(ll x) {
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) dp[i][j] = 0;
}
dp[0][0] = 1;
for (int i = 1; i <= n; i++) { //pos
for (int j = 1; j <= n; j++) { //groups
for (int k = 1; k <= i; k++) { //start pos
if (dp[k-1][j-1] && ((ar[i] - ar[k-1]) | x) == x)
dp[i][j] = 1;
}
}
}
for (int i = a; i <= b; i++) if (dp[n][i]) return 1;
return 0;
}
signed main() {
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) cin >> ar[i];
for (int i = 1; i <= n; i++) ar[i] += ar[i-1];
ll ans = 0;
for (int i = 0; i <= 60; i++) ans |= (1ll << i);
for (int i = 60; i >= 0; i--) if (check(ans ^ (1ll << i))) ans ^= 1ll << i;
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... |