#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
//#define endl "\n"
#define pii pair<int,int>
using namespace std;
const int MAXN = 2e3+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;
vector<vector<int>> sums(MAXN,vector<int>(MAXN));
int n,a,b;
int pref[MAXN];
void checka1(int& ans, int bt)
{
vector<int> dp(MAXN, inf);
dp[0] = 0;
for(int i=1; i<=n; i++)
{
for(int j=i; j>0; j--)
{
int trsum = pref[i]- pref[j-1];
int p = trsum|ans;
if(p == ans)dp[i] = min(dp[i],dp[j-1] + 1);
}
//cout << dp[i] << endl;
}
if(dp[n] > b)ans|=(1<<bt);
}
signed main()
{
ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0);
int tt=1;
//cin >> tt;
while(tt--)
{
cin >> n >> a >> b;
vector<int>niz(n);
for(int i=0; i<n; i++)
{
cin >> niz[i];
pref[i+1] = pref[i] + niz[i];
}
for(int i=0; i<n; i++)for(int j=i; j<n; j++)sums[i][j] = pref[i+1]-pref[j];
if(a == 1)
{
int mxbit = 50;
int rez = (1ll<<(mxbit+1))-1;
for(int i=mxbit; i>=0; i--)
{
rez ^= (1ll<<i);
checka1(rez, i);
}
cout << rez << endl;
}
else
{
}
}
}
/*
6 1 3
8 1 2 1 5 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
31836 KB |
Output is correct |
2 |
Correct |
15 ms |
31836 KB |
Output is correct |
3 |
Correct |
16 ms |
31832 KB |
Output is correct |
4 |
Correct |
15 ms |
31920 KB |
Output is correct |
5 |
Correct |
15 ms |
31836 KB |
Output is correct |
6 |
Correct |
15 ms |
31836 KB |
Output is correct |
7 |
Correct |
13 ms |
31836 KB |
Output is correct |
8 |
Correct |
16 ms |
31804 KB |
Output is correct |
9 |
Correct |
14 ms |
31836 KB |
Output is correct |
10 |
Correct |
16 ms |
31976 KB |
Output is correct |
11 |
Correct |
15 ms |
32064 KB |
Output is correct |
12 |
Correct |
18 ms |
31836 KB |
Output is correct |
13 |
Correct |
16 ms |
31832 KB |
Output is correct |
14 |
Incorrect |
14 ms |
31836 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
31836 KB |
Output is correct |
2 |
Correct |
13 ms |
31836 KB |
Output is correct |
3 |
Correct |
19 ms |
31868 KB |
Output is correct |
4 |
Correct |
14 ms |
31836 KB |
Output is correct |
5 |
Correct |
15 ms |
31812 KB |
Output is correct |
6 |
Correct |
15 ms |
31964 KB |
Output is correct |
7 |
Correct |
15 ms |
31880 KB |
Output is correct |
8 |
Correct |
18 ms |
31796 KB |
Output is correct |
9 |
Correct |
15 ms |
31836 KB |
Output is correct |
10 |
Correct |
15 ms |
31992 KB |
Output is correct |
11 |
Correct |
15 ms |
31836 KB |
Output is correct |
12 |
Correct |
15 ms |
31820 KB |
Output is correct |
13 |
Correct |
14 ms |
31836 KB |
Output is correct |
14 |
Incorrect |
19 ms |
31832 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
31836 KB |
Output is correct |
2 |
Correct |
13 ms |
31836 KB |
Output is correct |
3 |
Correct |
14 ms |
31836 KB |
Output is correct |
4 |
Correct |
13 ms |
31932 KB |
Output is correct |
5 |
Correct |
16 ms |
31832 KB |
Output is correct |
6 |
Correct |
16 ms |
31832 KB |
Output is correct |
7 |
Correct |
23 ms |
31836 KB |
Output is correct |
8 |
Correct |
16 ms |
31832 KB |
Output is correct |
9 |
Correct |
14 ms |
31932 KB |
Output is correct |
10 |
Correct |
14 ms |
31832 KB |
Output is correct |
11 |
Correct |
16 ms |
31836 KB |
Output is correct |
12 |
Correct |
15 ms |
31924 KB |
Output is correct |
13 |
Correct |
15 ms |
31784 KB |
Output is correct |
14 |
Correct |
14 ms |
31836 KB |
Output is correct |
15 |
Correct |
15 ms |
31860 KB |
Output is correct |
16 |
Correct |
14 ms |
32020 KB |
Output is correct |
17 |
Correct |
14 ms |
31836 KB |
Output is correct |
18 |
Correct |
15 ms |
31836 KB |
Output is correct |
19 |
Correct |
16 ms |
31836 KB |
Output is correct |
20 |
Correct |
16 ms |
31836 KB |
Output is correct |
21 |
Correct |
14 ms |
31832 KB |
Output is correct |
22 |
Correct |
15 ms |
31836 KB |
Output is correct |
23 |
Correct |
15 ms |
31832 KB |
Output is correct |
24 |
Correct |
16 ms |
31836 KB |
Output is correct |
25 |
Correct |
18 ms |
31796 KB |
Output is correct |
26 |
Correct |
15 ms |
31836 KB |
Output is correct |
27 |
Correct |
14 ms |
31792 KB |
Output is correct |
28 |
Correct |
17 ms |
31832 KB |
Output is correct |
29 |
Correct |
17 ms |
31836 KB |
Output is correct |
30 |
Correct |
16 ms |
31836 KB |
Output is correct |
31 |
Correct |
17 ms |
31836 KB |
Output is correct |
32 |
Correct |
18 ms |
31836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
31836 KB |
Output is correct |
2 |
Correct |
15 ms |
31980 KB |
Output is correct |
3 |
Correct |
19 ms |
31836 KB |
Output is correct |
4 |
Correct |
15 ms |
31836 KB |
Output is correct |
5 |
Correct |
15 ms |
31836 KB |
Output is correct |
6 |
Correct |
17 ms |
31832 KB |
Output is correct |
7 |
Correct |
17 ms |
31836 KB |
Output is correct |
8 |
Correct |
15 ms |
31892 KB |
Output is correct |
9 |
Correct |
15 ms |
31836 KB |
Output is correct |
10 |
Correct |
15 ms |
31876 KB |
Output is correct |
11 |
Correct |
19 ms |
31836 KB |
Output is correct |
12 |
Correct |
16 ms |
31836 KB |
Output is correct |
13 |
Correct |
14 ms |
31916 KB |
Output is correct |
14 |
Incorrect |
14 ms |
31836 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
31836 KB |
Output is correct |
2 |
Correct |
20 ms |
31796 KB |
Output is correct |
3 |
Correct |
21 ms |
31836 KB |
Output is correct |
4 |
Correct |
16 ms |
31836 KB |
Output is correct |
5 |
Correct |
16 ms |
31836 KB |
Output is correct |
6 |
Correct |
15 ms |
31836 KB |
Output is correct |
7 |
Correct |
16 ms |
31836 KB |
Output is correct |
8 |
Correct |
16 ms |
31836 KB |
Output is correct |
9 |
Correct |
16 ms |
31836 KB |
Output is correct |
10 |
Correct |
15 ms |
31880 KB |
Output is correct |
11 |
Correct |
17 ms |
31836 KB |
Output is correct |
12 |
Correct |
16 ms |
31836 KB |
Output is correct |
13 |
Correct |
15 ms |
31836 KB |
Output is correct |
14 |
Correct |
17 ms |
31800 KB |
Output is correct |
15 |
Correct |
16 ms |
31836 KB |
Output is correct |
16 |
Correct |
15 ms |
31836 KB |
Output is correct |
17 |
Incorrect |
18 ms |
31836 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |