#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|=(1ll<<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
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
31836 KB |
Output is correct |
2 |
Correct |
15 ms |
31836 KB |
Output is correct |
3 |
Correct |
15 ms |
31984 KB |
Output is correct |
4 |
Correct |
15 ms |
31884 KB |
Output is correct |
5 |
Correct |
15 ms |
31844 KB |
Output is correct |
6 |
Correct |
16 ms |
31984 KB |
Output is correct |
7 |
Correct |
15 ms |
31836 KB |
Output is correct |
8 |
Correct |
16 ms |
31832 KB |
Output is correct |
9 |
Correct |
21 ms |
31836 KB |
Output is correct |
10 |
Correct |
15 ms |
31932 KB |
Output is correct |
11 |
Correct |
13 ms |
31848 KB |
Output is correct |
12 |
Correct |
15 ms |
31836 KB |
Output is correct |
13 |
Correct |
15 ms |
31836 KB |
Output is correct |
14 |
Incorrect |
15 ms |
31944 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
31836 KB |
Output is correct |
2 |
Correct |
15 ms |
31832 KB |
Output is correct |
3 |
Correct |
15 ms |
31836 KB |
Output is correct |
4 |
Correct |
15 ms |
31864 KB |
Output is correct |
5 |
Correct |
16 ms |
31832 KB |
Output is correct |
6 |
Correct |
18 ms |
31792 KB |
Output is correct |
7 |
Correct |
16 ms |
31836 KB |
Output is correct |
8 |
Correct |
15 ms |
31832 KB |
Output is correct |
9 |
Correct |
15 ms |
31836 KB |
Output is correct |
10 |
Correct |
15 ms |
31956 KB |
Output is correct |
11 |
Correct |
15 ms |
31848 KB |
Output is correct |
12 |
Correct |
15 ms |
31836 KB |
Output is correct |
13 |
Correct |
16 ms |
31836 KB |
Output is correct |
14 |
Incorrect |
15 ms |
31836 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
31832 KB |
Output is correct |
2 |
Correct |
15 ms |
31836 KB |
Output is correct |
3 |
Correct |
15 ms |
31836 KB |
Output is correct |
4 |
Correct |
16 ms |
31832 KB |
Output is correct |
5 |
Correct |
16 ms |
31836 KB |
Output is correct |
6 |
Correct |
15 ms |
31832 KB |
Output is correct |
7 |
Correct |
16 ms |
31836 KB |
Output is correct |
8 |
Correct |
13 ms |
31780 KB |
Output is correct |
9 |
Correct |
14 ms |
31836 KB |
Output is correct |
10 |
Correct |
16 ms |
31836 KB |
Output is correct |
11 |
Correct |
14 ms |
31836 KB |
Output is correct |
12 |
Correct |
16 ms |
31968 KB |
Output is correct |
13 |
Correct |
20 ms |
31832 KB |
Output is correct |
14 |
Correct |
22 ms |
31836 KB |
Output is correct |
15 |
Correct |
17 ms |
31844 KB |
Output is correct |
16 |
Correct |
16 ms |
31904 KB |
Output is correct |
17 |
Correct |
16 ms |
31964 KB |
Output is correct |
18 |
Correct |
17 ms |
31836 KB |
Output is correct |
19 |
Correct |
15 ms |
31884 KB |
Output is correct |
20 |
Correct |
16 ms |
31836 KB |
Output is correct |
21 |
Correct |
15 ms |
31888 KB |
Output is correct |
22 |
Correct |
16 ms |
31836 KB |
Output is correct |
23 |
Correct |
17 ms |
31884 KB |
Output is correct |
24 |
Correct |
15 ms |
31836 KB |
Output is correct |
25 |
Correct |
17 ms |
31836 KB |
Output is correct |
26 |
Correct |
16 ms |
31832 KB |
Output is correct |
27 |
Correct |
16 ms |
31836 KB |
Output is correct |
28 |
Correct |
16 ms |
31796 KB |
Output is correct |
29 |
Correct |
16 ms |
31992 KB |
Output is correct |
30 |
Correct |
16 ms |
31836 KB |
Output is correct |
31 |
Correct |
15 ms |
31964 KB |
Output is correct |
32 |
Correct |
18 ms |
31832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
31836 KB |
Output is correct |
2 |
Correct |
15 ms |
31836 KB |
Output is correct |
3 |
Correct |
15 ms |
31900 KB |
Output is correct |
4 |
Correct |
15 ms |
31832 KB |
Output is correct |
5 |
Correct |
16 ms |
31836 KB |
Output is correct |
6 |
Correct |
15 ms |
31968 KB |
Output is correct |
7 |
Correct |
16 ms |
31836 KB |
Output is correct |
8 |
Correct |
15 ms |
31836 KB |
Output is correct |
9 |
Correct |
16 ms |
31832 KB |
Output is correct |
10 |
Correct |
16 ms |
31836 KB |
Output is correct |
11 |
Correct |
15 ms |
31836 KB |
Output is correct |
12 |
Correct |
15 ms |
31832 KB |
Output is correct |
13 |
Correct |
17 ms |
31832 KB |
Output is correct |
14 |
Incorrect |
15 ms |
31836 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
31836 KB |
Output is correct |
2 |
Correct |
15 ms |
31904 KB |
Output is correct |
3 |
Correct |
15 ms |
31836 KB |
Output is correct |
4 |
Correct |
14 ms |
31864 KB |
Output is correct |
5 |
Correct |
15 ms |
31952 KB |
Output is correct |
6 |
Correct |
15 ms |
31836 KB |
Output is correct |
7 |
Correct |
17 ms |
31836 KB |
Output is correct |
8 |
Correct |
15 ms |
31836 KB |
Output is correct |
9 |
Correct |
15 ms |
31836 KB |
Output is correct |
10 |
Correct |
13 ms |
31832 KB |
Output is correct |
11 |
Correct |
16 ms |
32000 KB |
Output is correct |
12 |
Correct |
16 ms |
31836 KB |
Output is correct |
13 |
Correct |
15 ms |
31836 KB |
Output is correct |
14 |
Correct |
16 ms |
31832 KB |
Output is correct |
15 |
Correct |
15 ms |
31836 KB |
Output is correct |
16 |
Correct |
14 ms |
31852 KB |
Output is correct |
17 |
Correct |
15 ms |
31780 KB |
Output is correct |
18 |
Correct |
16 ms |
31848 KB |
Output is correct |
19 |
Correct |
15 ms |
32008 KB |
Output is correct |
20 |
Correct |
14 ms |
31840 KB |
Output is correct |
21 |
Correct |
15 ms |
31844 KB |
Output is correct |
22 |
Correct |
17 ms |
31836 KB |
Output is correct |
23 |
Correct |
16 ms |
31836 KB |
Output is correct |
24 |
Correct |
15 ms |
31816 KB |
Output is correct |
25 |
Correct |
14 ms |
31892 KB |
Output is correct |
26 |
Correct |
16 ms |
31836 KB |
Output is correct |
27 |
Correct |
15 ms |
31836 KB |
Output is correct |
28 |
Correct |
16 ms |
31836 KB |
Output is correct |
29 |
Correct |
16 ms |
31832 KB |
Output is correct |
30 |
Correct |
16 ms |
31836 KB |
Output is correct |
31 |
Correct |
16 ms |
31836 KB |
Output is correct |
32 |
Correct |
15 ms |
31836 KB |
Output is correct |
33 |
Correct |
20 ms |
31836 KB |
Output is correct |
34 |
Correct |
16 ms |
31836 KB |
Output is correct |
35 |
Correct |
17 ms |
31772 KB |
Output is correct |
36 |
Correct |
15 ms |
31836 KB |
Output is correct |
37 |
Correct |
16 ms |
31836 KB |
Output is correct |
38 |
Correct |
14 ms |
32008 KB |
Output is correct |
39 |
Correct |
16 ms |
31832 KB |
Output is correct |
40 |
Correct |
16 ms |
31836 KB |
Output is correct |
41 |
Correct |
15 ms |
31836 KB |
Output is correct |
42 |
Correct |
20 ms |
31832 KB |
Output is correct |
43 |
Correct |
15 ms |
32088 KB |
Output is correct |
44 |
Correct |
16 ms |
31832 KB |
Output is correct |
45 |
Correct |
16 ms |
31832 KB |
Output is correct |
46 |
Correct |
15 ms |
31836 KB |
Output is correct |
47 |
Correct |
16 ms |
31832 KB |
Output is correct |
48 |
Correct |
21 ms |
31832 KB |
Output is correct |
49 |
Correct |
14 ms |
32000 KB |
Output is correct |
50 |
Correct |
16 ms |
31920 KB |
Output is correct |
51 |
Correct |
15 ms |
31976 KB |
Output is correct |
52 |
Correct |
23 ms |
31832 KB |
Output is correct |
53 |
Correct |
26 ms |
31836 KB |
Output is correct |
54 |
Correct |
36 ms |
32044 KB |
Output is correct |
55 |
Correct |
35 ms |
32028 KB |
Output is correct |
56 |
Correct |
95 ms |
31836 KB |
Output is correct |
57 |
Correct |
90 ms |
31832 KB |
Output is correct |
58 |
Correct |
96 ms |
32040 KB |
Output is correct |
59 |
Correct |
90 ms |
31832 KB |
Output is correct |
60 |
Correct |
96 ms |
32080 KB |
Output is correct |
61 |
Correct |
15 ms |
31896 KB |
Output is correct |
62 |
Correct |
26 ms |
32024 KB |
Output is correct |
63 |
Correct |
39 ms |
31836 KB |
Output is correct |
64 |
Correct |
35 ms |
31836 KB |
Output is correct |
65 |
Correct |
55 ms |
32036 KB |
Output is correct |
66 |
Correct |
73 ms |
31836 KB |
Output is correct |
67 |
Correct |
96 ms |
31836 KB |
Output is correct |
68 |
Correct |
96 ms |
31836 KB |
Output is correct |
69 |
Correct |
102 ms |
32044 KB |
Output is correct |