#include <bits/stdc++.h>
#define llint long long
#define fi first
#define se second
#define BIT(x, i) ((x>>i)&1ll)
#define MASK(i) (1ll<<i)
#define db(x) cout << #x << " = " << x << endl;
using namespace std;
void openFile() {
ios_base :: sync_with_stdio(false);
cin.tie(NULL);
#ifdef Tr___
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
#else
//freopen("tname.inp", "r", stdin);
//freopen("tname.out", "w", stdout);
#endif
}
template <typename T>
inline void read(T &ret){
register char c = getchar(); bool neg = false; ret = 0;
while (c < '0' || c > '9'){ if (c == '-') neg = true; c = getchar(); }
while (c >= '0' && c <= '9'){ ret = (ret << 1) + (ret << 3) + c - '0';
c = getchar(); }
if (neg) ret = -ret;
}
template <typename T>
void write(T x){
if (x < 0){ putchar('-'); x = -x; }
if (x >= 10) write(x / 10); putchar(x % 10 + 48);
}
const int maxn = 2e3 + 5;
const int maxm = 1e2 + 5;
const llint inf = 1e9 + 7;
int N, A, B;
int a[maxn];
llint s[maxn];
void enter() {
cin >> N >> A >> B;
for (int i = 1; i <= N; ++i) {
cin >> a[i];
s[i] = s[i - 1] + a[i];
}
}
void solve1() {
llint ans = 0;
llint state = 0;
bool f[maxm][maxm];
for (int p = 50; p >= 0; --p) {
state |= MASK(p);
fill_n(&f[0][0], maxm * maxm, false);
f[0][0] = true;
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= i; ++j) {
for (int k = 0; k < i; ++k) {
if ((state & (s[i] - s[k])) == 0) f[i][j] |= f[k][j - 1];
}
}
}
bool ok = false;
for (int i = A; i <= B; ++i) {
ok |= f[N][i];
}
if (!ok) {
state ^= MASK(p);
ans = ans + MASK(p);
}
}
cout << ans << endl;
}
void solve2() {
llint ans = 0;
llint state = 0;
int f[maxn];
for (int p = 50; p >= 0; --p) {
state |= MASK(p);
fill_n(f, maxn, inf);
f[0] = 0;
for (int i = 1; i <= N; ++i) {
for (int j = 0; j < i; ++j) {
if (((s[i] - s[j]) & state) == 0) {
f[i] = min(f[i], f[j] + 1);
}
}
}
if (f[N] > B) {
state ^= MASK(p);
ans = ans + MASK(p);
}
}
cout << ans << endl;
}
void solve() {
if (N <= 100) {
solve1();
}
else {
solve2();
}
}
int main() {
openFile();
enter();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2200 KB |
Output is correct |
2 |
Correct |
0 ms |
2200 KB |
Output is correct |
3 |
Correct |
0 ms |
2200 KB |
Output is correct |
4 |
Correct |
0 ms |
2200 KB |
Output is correct |
5 |
Correct |
0 ms |
2200 KB |
Output is correct |
6 |
Correct |
0 ms |
2200 KB |
Output is correct |
7 |
Correct |
0 ms |
2200 KB |
Output is correct |
8 |
Correct |
0 ms |
2200 KB |
Output is correct |
9 |
Correct |
0 ms |
2200 KB |
Output is correct |
10 |
Correct |
0 ms |
2200 KB |
Output is correct |
11 |
Correct |
0 ms |
2200 KB |
Output is correct |
12 |
Correct |
0 ms |
2200 KB |
Output is correct |
13 |
Correct |
0 ms |
2200 KB |
Output is correct |
14 |
Correct |
0 ms |
2200 KB |
Output is correct |
15 |
Correct |
0 ms |
2200 KB |
Output is correct |
16 |
Correct |
0 ms |
2200 KB |
Output is correct |
17 |
Correct |
0 ms |
2200 KB |
Output is correct |
18 |
Correct |
0 ms |
2200 KB |
Output is correct |
19 |
Correct |
0 ms |
2200 KB |
Output is correct |
20 |
Correct |
0 ms |
2200 KB |
Output is correct |
21 |
Correct |
0 ms |
2200 KB |
Output is correct |
22 |
Correct |
0 ms |
2200 KB |
Output is correct |
23 |
Correct |
0 ms |
2200 KB |
Output is correct |
24 |
Correct |
0 ms |
2200 KB |
Output is correct |
25 |
Correct |
0 ms |
2200 KB |
Output is correct |
26 |
Correct |
0 ms |
2200 KB |
Output is correct |
27 |
Correct |
0 ms |
2200 KB |
Output is correct |
28 |
Correct |
0 ms |
2200 KB |
Output is correct |
29 |
Correct |
0 ms |
2200 KB |
Output is correct |
30 |
Correct |
0 ms |
2200 KB |
Output is correct |
31 |
Correct |
0 ms |
2200 KB |
Output is correct |
32 |
Correct |
0 ms |
2200 KB |
Output is correct |
33 |
Correct |
0 ms |
2200 KB |
Output is correct |
34 |
Correct |
0 ms |
2200 KB |
Output is correct |
35 |
Correct |
0 ms |
2200 KB |
Output is correct |
36 |
Correct |
0 ms |
2200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2200 KB |
Output is correct |
2 |
Correct |
0 ms |
2200 KB |
Output is correct |
3 |
Correct |
0 ms |
2200 KB |
Output is correct |
4 |
Correct |
0 ms |
2200 KB |
Output is correct |
5 |
Correct |
0 ms |
2200 KB |
Output is correct |
6 |
Correct |
0 ms |
2200 KB |
Output is correct |
7 |
Correct |
0 ms |
2200 KB |
Output is correct |
8 |
Correct |
0 ms |
2200 KB |
Output is correct |
9 |
Correct |
0 ms |
2200 KB |
Output is correct |
10 |
Correct |
0 ms |
2200 KB |
Output is correct |
11 |
Correct |
0 ms |
2200 KB |
Output is correct |
12 |
Correct |
0 ms |
2200 KB |
Output is correct |
13 |
Correct |
0 ms |
2200 KB |
Output is correct |
14 |
Correct |
0 ms |
2200 KB |
Output is correct |
15 |
Correct |
0 ms |
2200 KB |
Output is correct |
16 |
Correct |
0 ms |
2200 KB |
Output is correct |
17 |
Correct |
0 ms |
2200 KB |
Output is correct |
18 |
Correct |
0 ms |
2200 KB |
Output is correct |
19 |
Correct |
0 ms |
2200 KB |
Output is correct |
20 |
Correct |
0 ms |
2200 KB |
Output is correct |
21 |
Correct |
0 ms |
2200 KB |
Output is correct |
22 |
Correct |
0 ms |
2200 KB |
Output is correct |
23 |
Correct |
0 ms |
2200 KB |
Output is correct |
24 |
Correct |
0 ms |
2200 KB |
Output is correct |
25 |
Correct |
0 ms |
2200 KB |
Output is correct |
26 |
Correct |
0 ms |
2200 KB |
Output is correct |
27 |
Correct |
0 ms |
2200 KB |
Output is correct |
28 |
Correct |
0 ms |
2200 KB |
Output is correct |
29 |
Correct |
0 ms |
2200 KB |
Output is correct |
30 |
Correct |
3 ms |
2200 KB |
Output is correct |
31 |
Correct |
3 ms |
2200 KB |
Output is correct |
32 |
Correct |
3 ms |
2200 KB |
Output is correct |
33 |
Correct |
3 ms |
2200 KB |
Output is correct |
34 |
Correct |
6 ms |
2200 KB |
Output is correct |
35 |
Correct |
3 ms |
2200 KB |
Output is correct |
36 |
Correct |
6 ms |
2200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2200 KB |
Output is correct |
2 |
Correct |
0 ms |
2200 KB |
Output is correct |
3 |
Correct |
0 ms |
2200 KB |
Output is correct |
4 |
Correct |
0 ms |
2200 KB |
Output is correct |
5 |
Correct |
0 ms |
2200 KB |
Output is correct |
6 |
Correct |
0 ms |
2200 KB |
Output is correct |
7 |
Correct |
0 ms |
2200 KB |
Output is correct |
8 |
Correct |
0 ms |
2200 KB |
Output is correct |
9 |
Correct |
0 ms |
2200 KB |
Output is correct |
10 |
Correct |
0 ms |
2200 KB |
Output is correct |
11 |
Correct |
0 ms |
2200 KB |
Output is correct |
12 |
Correct |
0 ms |
2200 KB |
Output is correct |
13 |
Correct |
0 ms |
2200 KB |
Output is correct |
14 |
Correct |
0 ms |
2200 KB |
Output is correct |
15 |
Correct |
0 ms |
2200 KB |
Output is correct |
16 |
Correct |
0 ms |
2200 KB |
Output is correct |
17 |
Correct |
3 ms |
2200 KB |
Output is correct |
18 |
Correct |
3 ms |
2200 KB |
Output is correct |
19 |
Correct |
3 ms |
2200 KB |
Output is correct |
20 |
Correct |
3 ms |
2200 KB |
Output is correct |
21 |
Correct |
3 ms |
2200 KB |
Output is correct |
22 |
Correct |
3 ms |
2200 KB |
Output is correct |
23 |
Correct |
3 ms |
2200 KB |
Output is correct |
24 |
Correct |
3 ms |
2200 KB |
Output is correct |
25 |
Correct |
9 ms |
2200 KB |
Output is correct |
26 |
Correct |
16 ms |
2200 KB |
Output is correct |
27 |
Correct |
26 ms |
2200 KB |
Output is correct |
28 |
Correct |
36 ms |
2200 KB |
Output is correct |
29 |
Correct |
39 ms |
2200 KB |
Output is correct |
30 |
Correct |
43 ms |
2200 KB |
Output is correct |
31 |
Correct |
39 ms |
2200 KB |
Output is correct |
32 |
Correct |
36 ms |
2200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2200 KB |
Output is correct |
2 |
Correct |
0 ms |
2200 KB |
Output is correct |
3 |
Correct |
0 ms |
2200 KB |
Output is correct |
4 |
Correct |
0 ms |
2200 KB |
Output is correct |
5 |
Correct |
0 ms |
2200 KB |
Output is correct |
6 |
Correct |
0 ms |
2200 KB |
Output is correct |
7 |
Correct |
0 ms |
2200 KB |
Output is correct |
8 |
Correct |
0 ms |
2200 KB |
Output is correct |
9 |
Correct |
0 ms |
2200 KB |
Output is correct |
10 |
Correct |
0 ms |
2200 KB |
Output is correct |
11 |
Correct |
0 ms |
2200 KB |
Output is correct |
12 |
Correct |
0 ms |
2200 KB |
Output is correct |
13 |
Correct |
0 ms |
2200 KB |
Output is correct |
14 |
Correct |
0 ms |
2200 KB |
Output is correct |
15 |
Correct |
0 ms |
2200 KB |
Output is correct |
16 |
Correct |
0 ms |
2200 KB |
Output is correct |
17 |
Correct |
0 ms |
2200 KB |
Output is correct |
18 |
Correct |
0 ms |
2200 KB |
Output is correct |
19 |
Correct |
0 ms |
2200 KB |
Output is correct |
20 |
Correct |
0 ms |
2200 KB |
Output is correct |
21 |
Correct |
0 ms |
2200 KB |
Output is correct |
22 |
Correct |
0 ms |
2200 KB |
Output is correct |
23 |
Correct |
0 ms |
2200 KB |
Output is correct |
24 |
Correct |
0 ms |
2200 KB |
Output is correct |
25 |
Correct |
0 ms |
2200 KB |
Output is correct |
26 |
Correct |
0 ms |
2200 KB |
Output is correct |
27 |
Correct |
0 ms |
2200 KB |
Output is correct |
28 |
Correct |
0 ms |
2200 KB |
Output is correct |
29 |
Correct |
0 ms |
2200 KB |
Output is correct |
30 |
Correct |
0 ms |
2200 KB |
Output is correct |
31 |
Correct |
0 ms |
2200 KB |
Output is correct |
32 |
Correct |
0 ms |
2200 KB |
Output is correct |
33 |
Correct |
0 ms |
2200 KB |
Output is correct |
34 |
Correct |
0 ms |
2200 KB |
Output is correct |
35 |
Correct |
0 ms |
2200 KB |
Output is correct |
36 |
Correct |
0 ms |
2200 KB |
Output is correct |
37 |
Correct |
0 ms |
2200 KB |
Output is correct |
38 |
Correct |
0 ms |
2200 KB |
Output is correct |
39 |
Correct |
0 ms |
2200 KB |
Output is correct |
40 |
Correct |
3 ms |
2200 KB |
Output is correct |
41 |
Correct |
3 ms |
2200 KB |
Output is correct |
42 |
Correct |
6 ms |
2200 KB |
Output is correct |
43 |
Correct |
6 ms |
2200 KB |
Output is correct |
44 |
Correct |
6 ms |
2200 KB |
Output is correct |
45 |
Correct |
3 ms |
2200 KB |
Output is correct |
46 |
Correct |
3 ms |
2200 KB |
Output is correct |
47 |
Correct |
3 ms |
2200 KB |
Output is correct |
48 |
Correct |
9 ms |
2200 KB |
Output is correct |
49 |
Correct |
16 ms |
2200 KB |
Output is correct |
50 |
Correct |
26 ms |
2200 KB |
Output is correct |
51 |
Correct |
36 ms |
2200 KB |
Output is correct |
52 |
Correct |
43 ms |
2200 KB |
Output is correct |
53 |
Correct |
36 ms |
2200 KB |
Output is correct |
54 |
Correct |
36 ms |
2200 KB |
Output is correct |
55 |
Correct |
36 ms |
2200 KB |
Output is correct |
56 |
Correct |
3 ms |
2200 KB |
Output is correct |
57 |
Correct |
13 ms |
2200 KB |
Output is correct |
58 |
Correct |
19 ms |
2200 KB |
Output is correct |
59 |
Correct |
26 ms |
2200 KB |
Output is correct |
60 |
Correct |
26 ms |
2200 KB |
Output is correct |
61 |
Correct |
26 ms |
2200 KB |
Output is correct |
62 |
Correct |
29 ms |
2200 KB |
Output is correct |
63 |
Correct |
29 ms |
2200 KB |
Output is correct |
64 |
Correct |
26 ms |
2200 KB |
Output is correct |
65 |
Correct |
3 ms |
2200 KB |
Output is correct |
66 |
Correct |
9 ms |
2200 KB |
Output is correct |
67 |
Correct |
13 ms |
2200 KB |
Output is correct |
68 |
Correct |
19 ms |
2200 KB |
Output is correct |
69 |
Correct |
26 ms |
2200 KB |
Output is correct |
70 |
Correct |
26 ms |
2200 KB |
Output is correct |
71 |
Correct |
26 ms |
2200 KB |
Output is correct |
72 |
Correct |
23 ms |
2200 KB |
Output is correct |
73 |
Correct |
26 ms |
2200 KB |
Output is correct |
74 |
Correct |
26 ms |
2200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2200 KB |
Output is correct |
2 |
Correct |
0 ms |
2200 KB |
Output is correct |
3 |
Correct |
0 ms |
2200 KB |
Output is correct |
4 |
Correct |
0 ms |
2200 KB |
Output is correct |
5 |
Correct |
0 ms |
2200 KB |
Output is correct |
6 |
Correct |
0 ms |
2200 KB |
Output is correct |
7 |
Correct |
0 ms |
2200 KB |
Output is correct |
8 |
Correct |
0 ms |
2200 KB |
Output is correct |
9 |
Correct |
0 ms |
2200 KB |
Output is correct |
10 |
Correct |
0 ms |
2200 KB |
Output is correct |
11 |
Correct |
0 ms |
2200 KB |
Output is correct |
12 |
Correct |
0 ms |
2200 KB |
Output is correct |
13 |
Correct |
0 ms |
2200 KB |
Output is correct |
14 |
Correct |
0 ms |
2200 KB |
Output is correct |
15 |
Correct |
0 ms |
2200 KB |
Output is correct |
16 |
Correct |
0 ms |
2200 KB |
Output is correct |
17 |
Correct |
0 ms |
2200 KB |
Output is correct |
18 |
Correct |
0 ms |
2200 KB |
Output is correct |
19 |
Correct |
0 ms |
2200 KB |
Output is correct |
20 |
Correct |
0 ms |
2200 KB |
Output is correct |
21 |
Correct |
0 ms |
2200 KB |
Output is correct |
22 |
Correct |
0 ms |
2200 KB |
Output is correct |
23 |
Correct |
0 ms |
2200 KB |
Output is correct |
24 |
Correct |
0 ms |
2200 KB |
Output is correct |
25 |
Correct |
0 ms |
2200 KB |
Output is correct |
26 |
Correct |
0 ms |
2200 KB |
Output is correct |
27 |
Correct |
3 ms |
2200 KB |
Output is correct |
28 |
Correct |
6 ms |
2200 KB |
Output is correct |
29 |
Correct |
3 ms |
2200 KB |
Output is correct |
30 |
Correct |
3 ms |
2200 KB |
Output is correct |
31 |
Correct |
3 ms |
2200 KB |
Output is correct |
32 |
Correct |
3 ms |
2200 KB |
Output is correct |
33 |
Correct |
3 ms |
2200 KB |
Output is correct |
34 |
Correct |
3 ms |
2200 KB |
Output is correct |
35 |
Correct |
9 ms |
2200 KB |
Output is correct |
36 |
Correct |
16 ms |
2200 KB |
Output is correct |
37 |
Correct |
26 ms |
2200 KB |
Output is correct |
38 |
Correct |
36 ms |
2200 KB |
Output is correct |
39 |
Correct |
36 ms |
2200 KB |
Output is correct |
40 |
Correct |
39 ms |
2200 KB |
Output is correct |
41 |
Correct |
36 ms |
2200 KB |
Output is correct |
42 |
Correct |
36 ms |
2200 KB |
Output is correct |
43 |
Correct |
3 ms |
2200 KB |
Output is correct |
44 |
Correct |
13 ms |
2200 KB |
Output is correct |
45 |
Correct |
19 ms |
2200 KB |
Output is correct |
46 |
Correct |
26 ms |
2200 KB |
Output is correct |
47 |
Correct |
29 ms |
2200 KB |
Output is correct |
48 |
Correct |
26 ms |
2200 KB |
Output is correct |
49 |
Correct |
26 ms |
2200 KB |
Output is correct |
50 |
Correct |
26 ms |
2200 KB |
Output is correct |
51 |
Correct |
0 ms |
2200 KB |
Output is correct |
52 |
Correct |
13 ms |
2200 KB |
Output is correct |
53 |
Correct |
19 ms |
2200 KB |
Output is correct |
54 |
Correct |
46 ms |
2200 KB |
Output is correct |
55 |
Correct |
39 ms |
2200 KB |
Output is correct |
56 |
Correct |
166 ms |
2200 KB |
Output is correct |
57 |
Correct |
153 ms |
2200 KB |
Output is correct |
58 |
Correct |
149 ms |
2200 KB |
Output is correct |
59 |
Correct |
149 ms |
2200 KB |
Output is correct |
60 |
Correct |
159 ms |
2200 KB |
Output is correct |
61 |
Correct |
0 ms |
2200 KB |
Output is correct |
62 |
Correct |
23 ms |
2200 KB |
Output is correct |
63 |
Correct |
46 ms |
2200 KB |
Output is correct |
64 |
Correct |
39 ms |
2200 KB |
Output is correct |
65 |
Correct |
76 ms |
2200 KB |
Output is correct |
66 |
Correct |
129 ms |
2200 KB |
Output is correct |
67 |
Correct |
153 ms |
2200 KB |
Output is correct |
68 |
Correct |
156 ms |
2200 KB |
Output is correct |
69 |
Correct |
149 ms |
2200 KB |
Output is correct |