#pragma GCC optimize("unroll-loops,O3")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define FOR(i,x,n) for(int i=x; i<n; i++)
#define F0R(i,n) FOR(i,0,n)
#define ROF(i,x,n) for(int i=n-1; i>=x; i--)
#define R0F(i,n) ROF(i,0,n)
#define WTF cout << "WTF" << endl
#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define F first
#define S second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
const int MAXN = 100 + 7;
const int ALPHA = 27;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int LOG = 22;
int dp[102][102][2050];
int ns[MAXN], a, b, n;
int main() {
IOS;
cin >> n >> a >> b;
FOR(i, 1, n + 1) {
cin >> ns[i];
if (ns[i] > 20) return 0;
}
F0R(i, 2048) dp[0][0][i] = 1;
FOR(i, 1, n + 1) FOR(j, 1, b + 1) F0R(k, 2048) {
int po = 0;
ROF(x, 1, i + 1) {
po += ns[x];
if ((po & k) == po) dp[i][j][k] |= dp[x - 1][j - 1][k];
}
}
//cout << dp[6][2][11] << endl;
int minim = INF;
FOR(i, a, b + 1) F0R(j, 2048) if (dp[n][i][j]) minim = min(minim, j);
cout << minim;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
580 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
5 ms |
2124 KB |
Output is correct |
7 |
Correct |
2 ms |
836 KB |
Output is correct |
8 |
Correct |
3 ms |
836 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
2 ms |
844 KB |
Output is correct |
13 |
Correct |
11 ms |
3048 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
452 KB |
Output is correct |
18 |
Correct |
1 ms |
588 KB |
Output is correct |
19 |
Correct |
6 ms |
2124 KB |
Output is correct |
20 |
Correct |
2 ms |
716 KB |
Output is correct |
21 |
Correct |
4 ms |
1484 KB |
Output is correct |
22 |
Correct |
4 ms |
1484 KB |
Output is correct |
23 |
Correct |
5 ms |
1472 KB |
Output is correct |
24 |
Correct |
2 ms |
704 KB |
Output is correct |
25 |
Correct |
5 ms |
1484 KB |
Output is correct |
26 |
Correct |
8 ms |
2424 KB |
Output is correct |
27 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
568 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
448 KB |
Output is correct |
5 |
Correct |
1 ms |
448 KB |
Output is correct |
6 |
Correct |
5 ms |
2124 KB |
Output is correct |
7 |
Correct |
2 ms |
716 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
2 ms |
836 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
2 ms |
844 KB |
Output is correct |
13 |
Correct |
11 ms |
3148 KB |
Output is correct |
14 |
Correct |
1 ms |
448 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
568 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
2 ms |
588 KB |
Output is correct |
19 |
Correct |
6 ms |
2200 KB |
Output is correct |
20 |
Correct |
2 ms |
716 KB |
Output is correct |
21 |
Correct |
4 ms |
1484 KB |
Output is correct |
22 |
Correct |
4 ms |
1480 KB |
Output is correct |
23 |
Correct |
5 ms |
1544 KB |
Output is correct |
24 |
Correct |
2 ms |
716 KB |
Output is correct |
25 |
Correct |
4 ms |
1484 KB |
Output is correct |
26 |
Correct |
8 ms |
2500 KB |
Output is correct |
27 |
Correct |
13 ms |
3764 KB |
Output is correct |
28 |
Correct |
9 ms |
2368 KB |
Output is correct |
29 |
Correct |
10 ms |
2036 KB |
Output is correct |
30 |
Correct |
41 ms |
6508 KB |
Output is correct |
31 |
Correct |
66 ms |
8516 KB |
Output is correct |
32 |
Correct |
67 ms |
8564 KB |
Output is correct |
33 |
Correct |
5 ms |
964 KB |
Output is correct |
34 |
Correct |
66 ms |
8536 KB |
Output is correct |
35 |
Correct |
55 ms |
7280 KB |
Output is correct |
36 |
Correct |
34 ms |
4572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
7 ms |
2124 KB |
Output is correct |
7 |
Correct |
2 ms |
716 KB |
Output is correct |
8 |
Correct |
2 ms |
836 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
3 ms |
844 KB |
Output is correct |
11 |
Correct |
1 ms |
588 KB |
Output is correct |
12 |
Correct |
2 ms |
840 KB |
Output is correct |
13 |
Correct |
11 ms |
3124 KB |
Output is correct |
14 |
Correct |
12 ms |
3804 KB |
Output is correct |
15 |
Correct |
9 ms |
2392 KB |
Output is correct |
16 |
Correct |
10 ms |
1996 KB |
Output is correct |
17 |
Correct |
42 ms |
6592 KB |
Output is correct |
18 |
Correct |
68 ms |
8484 KB |
Output is correct |
19 |
Correct |
71 ms |
8560 KB |
Output is correct |
20 |
Correct |
5 ms |
972 KB |
Output is correct |
21 |
Correct |
65 ms |
8516 KB |
Output is correct |
22 |
Correct |
57 ms |
7308 KB |
Output is correct |
23 |
Correct |
34 ms |
4556 KB |
Output is correct |
24 |
Correct |
68 ms |
8644 KB |
Output is correct |
25 |
Correct |
55 ms |
5784 KB |
Output is correct |
26 |
Correct |
188 ms |
15168 KB |
Output is correct |
27 |
Correct |
646 ms |
40748 KB |
Output is correct |
28 |
Execution timed out |
1078 ms |
69232 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
452 KB |
Output is correct |
6 |
Correct |
6 ms |
2124 KB |
Output is correct |
7 |
Correct |
2 ms |
840 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
1 ms |
580 KB |
Output is correct |
12 |
Correct |
2 ms |
828 KB |
Output is correct |
13 |
Correct |
10 ms |
3156 KB |
Output is correct |
14 |
Correct |
1 ms |
440 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
572 KB |
Output is correct |
17 |
Correct |
1 ms |
448 KB |
Output is correct |
18 |
Correct |
1 ms |
704 KB |
Output is correct |
19 |
Correct |
5 ms |
2124 KB |
Output is correct |
20 |
Correct |
2 ms |
716 KB |
Output is correct |
21 |
Correct |
4 ms |
1480 KB |
Output is correct |
22 |
Correct |
5 ms |
1484 KB |
Output is correct |
23 |
Correct |
5 ms |
1484 KB |
Output is correct |
24 |
Correct |
2 ms |
716 KB |
Output is correct |
25 |
Correct |
4 ms |
1484 KB |
Output is correct |
26 |
Correct |
10 ms |
2508 KB |
Output is correct |
27 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
452 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
388 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
6 ms |
2124 KB |
Output is correct |
7 |
Correct |
2 ms |
716 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
2 ms |
580 KB |
Output is correct |
12 |
Correct |
2 ms |
828 KB |
Output is correct |
13 |
Correct |
10 ms |
3140 KB |
Output is correct |
14 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |