#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define clr(dp,i) memset(dp,i,sizeof(dp))
#define opt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
tree_order_statistics_node_update> oset;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const long long mod = 1e9+7;
const ld pi = 3.14159265358979323846264338327950288;
//========================================
ll n, l, r, sum[101], a[101], dp[101][101], ans;
ll h = (1LL << 60) - 1;
bool sol(ll T)
{
clr(dp, 0);
dp[0][0] = 1;
for(int j=1; j<=r; j++)
{
for(int i=j; i<=n; i++)
{
ll tmp = 0;
for(int k=0; k<i; k++)
{
ll enc = sum[i] - tmp;
enc ^= h;
//cout << sum[i] << " " << tmp << " " << b << " " << c << endl;
//cout << sum << " " << tmp << endl;
if(dp[k][j-1] && (enc & T) == T)
dp[i][j] = 1;
tmp += a[k];
}
}
}
for(int j=l; j<=r; j++)
{
if(dp[n][j])
return 1;
}
return 0;
}
int main()
{
opt;
cin >> n >> l >> r;
for(int i=0; i<n; i++)
cin >> a[i], sum[i+1] = sum[i] + a[i];
for(int i=60; i>=0; i--)
{
if(sol((ans | (1LL << i))))
ans |= (1LL << i);
}
cout << (ans^h) << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
524 KB |
Output is correct |
5 |
Correct |
3 ms |
572 KB |
Output is correct |
6 |
Correct |
3 ms |
648 KB |
Output is correct |
7 |
Correct |
2 ms |
724 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
3 ms |
724 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
3 ms |
740 KB |
Output is correct |
13 |
Correct |
3 ms |
740 KB |
Output is correct |
14 |
Correct |
3 ms |
740 KB |
Output is correct |
15 |
Correct |
2 ms |
740 KB |
Output is correct |
16 |
Correct |
2 ms |
740 KB |
Output is correct |
17 |
Correct |
3 ms |
740 KB |
Output is correct |
18 |
Correct |
2 ms |
740 KB |
Output is correct |
19 |
Correct |
2 ms |
740 KB |
Output is correct |
20 |
Correct |
3 ms |
740 KB |
Output is correct |
21 |
Correct |
3 ms |
740 KB |
Output is correct |
22 |
Correct |
4 ms |
740 KB |
Output is correct |
23 |
Correct |
2 ms |
740 KB |
Output is correct |
24 |
Correct |
3 ms |
796 KB |
Output is correct |
25 |
Correct |
3 ms |
796 KB |
Output is correct |
26 |
Correct |
2 ms |
796 KB |
Output is correct |
27 |
Correct |
3 ms |
796 KB |
Output is correct |
28 |
Correct |
3 ms |
796 KB |
Output is correct |
29 |
Correct |
2 ms |
796 KB |
Output is correct |
30 |
Correct |
3 ms |
796 KB |
Output is correct |
31 |
Correct |
3 ms |
796 KB |
Output is correct |
32 |
Correct |
2 ms |
796 KB |
Output is correct |
33 |
Correct |
3 ms |
832 KB |
Output is correct |
34 |
Correct |
3 ms |
840 KB |
Output is correct |
35 |
Correct |
3 ms |
840 KB |
Output is correct |
36 |
Correct |
3 ms |
840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
840 KB |
Output is correct |
2 |
Correct |
3 ms |
840 KB |
Output is correct |
3 |
Correct |
2 ms |
840 KB |
Output is correct |
4 |
Correct |
3 ms |
840 KB |
Output is correct |
5 |
Correct |
2 ms |
840 KB |
Output is correct |
6 |
Correct |
3 ms |
840 KB |
Output is correct |
7 |
Correct |
3 ms |
840 KB |
Output is correct |
8 |
Correct |
3 ms |
840 KB |
Output is correct |
9 |
Correct |
2 ms |
840 KB |
Output is correct |
10 |
Correct |
3 ms |
840 KB |
Output is correct |
11 |
Correct |
3 ms |
840 KB |
Output is correct |
12 |
Correct |
3 ms |
840 KB |
Output is correct |
13 |
Correct |
2 ms |
840 KB |
Output is correct |
14 |
Correct |
2 ms |
840 KB |
Output is correct |
15 |
Correct |
3 ms |
840 KB |
Output is correct |
16 |
Correct |
2 ms |
840 KB |
Output is correct |
17 |
Correct |
3 ms |
840 KB |
Output is correct |
18 |
Correct |
3 ms |
840 KB |
Output is correct |
19 |
Correct |
3 ms |
840 KB |
Output is correct |
20 |
Correct |
3 ms |
840 KB |
Output is correct |
21 |
Correct |
3 ms |
840 KB |
Output is correct |
22 |
Correct |
3 ms |
840 KB |
Output is correct |
23 |
Correct |
3 ms |
840 KB |
Output is correct |
24 |
Correct |
3 ms |
840 KB |
Output is correct |
25 |
Correct |
3 ms |
840 KB |
Output is correct |
26 |
Correct |
3 ms |
840 KB |
Output is correct |
27 |
Correct |
3 ms |
840 KB |
Output is correct |
28 |
Correct |
3 ms |
840 KB |
Output is correct |
29 |
Correct |
3 ms |
840 KB |
Output is correct |
30 |
Correct |
5 ms |
840 KB |
Output is correct |
31 |
Correct |
6 ms |
840 KB |
Output is correct |
32 |
Correct |
6 ms |
840 KB |
Output is correct |
33 |
Correct |
2 ms |
840 KB |
Output is correct |
34 |
Correct |
6 ms |
844 KB |
Output is correct |
35 |
Correct |
5 ms |
880 KB |
Output is correct |
36 |
Correct |
4 ms |
884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
888 KB |
Output is correct |
2 |
Correct |
2 ms |
888 KB |
Output is correct |
3 |
Correct |
3 ms |
888 KB |
Output is correct |
4 |
Correct |
3 ms |
888 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
924 KB |
Output is correct |
7 |
Correct |
2 ms |
924 KB |
Output is correct |
8 |
Correct |
3 ms |
924 KB |
Output is correct |
9 |
Correct |
3 ms |
924 KB |
Output is correct |
10 |
Correct |
3 ms |
924 KB |
Output is correct |
11 |
Correct |
2 ms |
924 KB |
Output is correct |
12 |
Correct |
2 ms |
924 KB |
Output is correct |
13 |
Correct |
3 ms |
924 KB |
Output is correct |
14 |
Correct |
3 ms |
924 KB |
Output is correct |
15 |
Correct |
3 ms |
924 KB |
Output is correct |
16 |
Correct |
3 ms |
924 KB |
Output is correct |
17 |
Correct |
5 ms |
924 KB |
Output is correct |
18 |
Correct |
6 ms |
928 KB |
Output is correct |
19 |
Correct |
6 ms |
928 KB |
Output is correct |
20 |
Correct |
2 ms |
928 KB |
Output is correct |
21 |
Correct |
5 ms |
928 KB |
Output is correct |
22 |
Correct |
5 ms |
928 KB |
Output is correct |
23 |
Correct |
4 ms |
928 KB |
Output is correct |
24 |
Correct |
6 ms |
928 KB |
Output is correct |
25 |
Correct |
5 ms |
928 KB |
Output is correct |
26 |
Correct |
10 ms |
928 KB |
Output is correct |
27 |
Correct |
25 ms |
928 KB |
Output is correct |
28 |
Correct |
38 ms |
928 KB |
Output is correct |
29 |
Correct |
39 ms |
928 KB |
Output is correct |
30 |
Correct |
3 ms |
928 KB |
Output is correct |
31 |
Correct |
31 ms |
972 KB |
Output is correct |
32 |
Correct |
64 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
972 KB |
Output is correct |
2 |
Correct |
3 ms |
972 KB |
Output is correct |
3 |
Correct |
2 ms |
972 KB |
Output is correct |
4 |
Correct |
2 ms |
972 KB |
Output is correct |
5 |
Correct |
2 ms |
972 KB |
Output is correct |
6 |
Correct |
3 ms |
972 KB |
Output is correct |
7 |
Correct |
3 ms |
972 KB |
Output is correct |
8 |
Correct |
3 ms |
972 KB |
Output is correct |
9 |
Correct |
3 ms |
972 KB |
Output is correct |
10 |
Correct |
3 ms |
972 KB |
Output is correct |
11 |
Correct |
3 ms |
972 KB |
Output is correct |
12 |
Correct |
2 ms |
972 KB |
Output is correct |
13 |
Correct |
3 ms |
972 KB |
Output is correct |
14 |
Correct |
2 ms |
972 KB |
Output is correct |
15 |
Correct |
3 ms |
1016 KB |
Output is correct |
16 |
Correct |
2 ms |
1016 KB |
Output is correct |
17 |
Correct |
2 ms |
1016 KB |
Output is correct |
18 |
Correct |
3 ms |
1016 KB |
Output is correct |
19 |
Correct |
3 ms |
1016 KB |
Output is correct |
20 |
Correct |
3 ms |
1016 KB |
Output is correct |
21 |
Correct |
3 ms |
1016 KB |
Output is correct |
22 |
Correct |
3 ms |
1016 KB |
Output is correct |
23 |
Correct |
3 ms |
1016 KB |
Output is correct |
24 |
Correct |
2 ms |
1016 KB |
Output is correct |
25 |
Correct |
3 ms |
1016 KB |
Output is correct |
26 |
Correct |
3 ms |
1016 KB |
Output is correct |
27 |
Correct |
2 ms |
1016 KB |
Output is correct |
28 |
Correct |
3 ms |
1016 KB |
Output is correct |
29 |
Correct |
3 ms |
1016 KB |
Output is correct |
30 |
Correct |
3 ms |
1016 KB |
Output is correct |
31 |
Correct |
2 ms |
1016 KB |
Output is correct |
32 |
Correct |
2 ms |
1016 KB |
Output is correct |
33 |
Correct |
3 ms |
1016 KB |
Output is correct |
34 |
Correct |
3 ms |
1016 KB |
Output is correct |
35 |
Correct |
3 ms |
1016 KB |
Output is correct |
36 |
Correct |
3 ms |
1016 KB |
Output is correct |
37 |
Correct |
3 ms |
1016 KB |
Output is correct |
38 |
Correct |
3 ms |
1016 KB |
Output is correct |
39 |
Correct |
3 ms |
1016 KB |
Output is correct |
40 |
Correct |
4 ms |
1016 KB |
Output is correct |
41 |
Correct |
5 ms |
1016 KB |
Output is correct |
42 |
Correct |
5 ms |
1016 KB |
Output is correct |
43 |
Correct |
2 ms |
1024 KB |
Output is correct |
44 |
Correct |
9 ms |
1024 KB |
Output is correct |
45 |
Correct |
6 ms |
1024 KB |
Output is correct |
46 |
Correct |
4 ms |
1024 KB |
Output is correct |
47 |
Correct |
5 ms |
1024 KB |
Output is correct |
48 |
Correct |
5 ms |
1024 KB |
Output is correct |
49 |
Correct |
11 ms |
1024 KB |
Output is correct |
50 |
Correct |
23 ms |
1024 KB |
Output is correct |
51 |
Correct |
35 ms |
1024 KB |
Output is correct |
52 |
Correct |
36 ms |
1024 KB |
Output is correct |
53 |
Correct |
3 ms |
1024 KB |
Output is correct |
54 |
Correct |
28 ms |
1024 KB |
Output is correct |
55 |
Correct |
33 ms |
1112 KB |
Output is correct |
56 |
Correct |
5 ms |
1112 KB |
Output is correct |
57 |
Correct |
10 ms |
1112 KB |
Output is correct |
58 |
Correct |
35 ms |
1112 KB |
Output is correct |
59 |
Correct |
45 ms |
1112 KB |
Output is correct |
60 |
Correct |
36 ms |
1112 KB |
Output is correct |
61 |
Correct |
4 ms |
1112 KB |
Output is correct |
62 |
Correct |
49 ms |
1112 KB |
Output is correct |
63 |
Correct |
33 ms |
1112 KB |
Output is correct |
64 |
Correct |
27 ms |
1112 KB |
Output is correct |
65 |
Correct |
6 ms |
1112 KB |
Output is correct |
66 |
Correct |
5 ms |
1112 KB |
Output is correct |
67 |
Correct |
10 ms |
1112 KB |
Output is correct |
68 |
Correct |
23 ms |
1128 KB |
Output is correct |
69 |
Correct |
36 ms |
1132 KB |
Output is correct |
70 |
Correct |
38 ms |
1132 KB |
Output is correct |
71 |
Correct |
4 ms |
1132 KB |
Output is correct |
72 |
Correct |
33 ms |
1132 KB |
Output is correct |
73 |
Correct |
51 ms |
1132 KB |
Output is correct |
74 |
Correct |
30 ms |
1136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1136 KB |
Output is correct |
2 |
Correct |
2 ms |
1136 KB |
Output is correct |
3 |
Correct |
2 ms |
1136 KB |
Output is correct |
4 |
Correct |
3 ms |
1136 KB |
Output is correct |
5 |
Correct |
3 ms |
1136 KB |
Output is correct |
6 |
Correct |
3 ms |
1136 KB |
Output is correct |
7 |
Correct |
2 ms |
1136 KB |
Output is correct |
8 |
Correct |
2 ms |
1136 KB |
Output is correct |
9 |
Correct |
2 ms |
1136 KB |
Output is correct |
10 |
Correct |
2 ms |
1136 KB |
Output is correct |
11 |
Correct |
2 ms |
1136 KB |
Output is correct |
12 |
Correct |
2 ms |
1136 KB |
Output is correct |
13 |
Correct |
3 ms |
1136 KB |
Output is correct |
14 |
Correct |
2 ms |
1136 KB |
Output is correct |
15 |
Correct |
2 ms |
1136 KB |
Output is correct |
16 |
Correct |
2 ms |
1136 KB |
Output is correct |
17 |
Correct |
2 ms |
1136 KB |
Output is correct |
18 |
Correct |
3 ms |
1136 KB |
Output is correct |
19 |
Correct |
2 ms |
1136 KB |
Output is correct |
20 |
Correct |
3 ms |
1136 KB |
Output is correct |
21 |
Correct |
3 ms |
1136 KB |
Output is correct |
22 |
Correct |
3 ms |
1136 KB |
Output is correct |
23 |
Correct |
3 ms |
1136 KB |
Output is correct |
24 |
Correct |
3 ms |
1136 KB |
Output is correct |
25 |
Correct |
3 ms |
1136 KB |
Output is correct |
26 |
Correct |
3 ms |
1136 KB |
Output is correct |
27 |
Correct |
5 ms |
1136 KB |
Output is correct |
28 |
Correct |
6 ms |
1136 KB |
Output is correct |
29 |
Correct |
5 ms |
1136 KB |
Output is correct |
30 |
Correct |
3 ms |
1136 KB |
Output is correct |
31 |
Correct |
5 ms |
1136 KB |
Output is correct |
32 |
Correct |
5 ms |
1136 KB |
Output is correct |
33 |
Correct |
4 ms |
1136 KB |
Output is correct |
34 |
Correct |
6 ms |
1136 KB |
Output is correct |
35 |
Correct |
6 ms |
1136 KB |
Output is correct |
36 |
Correct |
11 ms |
1136 KB |
Output is correct |
37 |
Correct |
30 ms |
1136 KB |
Output is correct |
38 |
Correct |
45 ms |
1136 KB |
Output is correct |
39 |
Correct |
44 ms |
1136 KB |
Output is correct |
40 |
Correct |
3 ms |
1136 KB |
Output is correct |
41 |
Correct |
29 ms |
1160 KB |
Output is correct |
42 |
Correct |
39 ms |
1160 KB |
Output is correct |
43 |
Correct |
8 ms |
1160 KB |
Output is correct |
44 |
Correct |
12 ms |
1160 KB |
Output is correct |
45 |
Correct |
21 ms |
1160 KB |
Output is correct |
46 |
Correct |
34 ms |
1160 KB |
Output is correct |
47 |
Correct |
38 ms |
1160 KB |
Output is correct |
48 |
Correct |
3 ms |
1160 KB |
Output is correct |
49 |
Correct |
38 ms |
1160 KB |
Output is correct |
50 |
Correct |
40 ms |
1160 KB |
Output is correct |
51 |
Execution timed out |
1095 ms |
1160 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |