#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair < int, int > PII;
#define F first
#define S second
#define mkp make_pair
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define y1 kekek
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
const ll ool = 1e18 + 9;
const int N = 2e3 + 6, oo = 1e9 + 9, base = 1e9 + 7;
int n, A, B, a[N], d[N][N];
int main() {
#ifdef krauch
freopen("input.txt", "r", stdin);
#endif
cin >> n >> A >> B;
forn(i, 1, n) {
cin >> a[i];
}
forn(j, 0, 2000) d[0][j] = oo;
d[0][0] = 0;
forn(i, 1, n) {
int sum = 0;
forn(j, 0, 2000) d[i][j] = oo;
for1(j, i, 1) {
sum += a[j];
forn(k, 0, 2000) {
d[i][k | sum] = min(d[i][k | sum], d[j - 1][k] + 1);
}
}
}
int pos = 2000;
forn(i, 0, 2000) {
if (d[n][i] <= B) {
pos = i;
break;
}
}
cout << pos << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
1 ms |
480 KB |
Output is correct |
3 |
Correct |
1 ms |
480 KB |
Output is correct |
4 |
Correct |
1 ms |
496 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
676 KB |
Output is correct |
7 |
Correct |
2 ms |
800 KB |
Output is correct |
8 |
Correct |
2 ms |
800 KB |
Output is correct |
9 |
Correct |
2 ms |
800 KB |
Output is correct |
10 |
Correct |
2 ms |
800 KB |
Output is correct |
11 |
Correct |
2 ms |
800 KB |
Output is correct |
12 |
Correct |
2 ms |
800 KB |
Output is correct |
13 |
Correct |
2 ms |
824 KB |
Output is correct |
14 |
Correct |
1 ms |
824 KB |
Output is correct |
15 |
Incorrect |
1 ms |
824 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
824 KB |
Output is correct |
2 |
Correct |
2 ms |
824 KB |
Output is correct |
3 |
Correct |
1 ms |
824 KB |
Output is correct |
4 |
Correct |
1 ms |
824 KB |
Output is correct |
5 |
Correct |
2 ms |
824 KB |
Output is correct |
6 |
Correct |
2 ms |
824 KB |
Output is correct |
7 |
Correct |
2 ms |
824 KB |
Output is correct |
8 |
Correct |
2 ms |
824 KB |
Output is correct |
9 |
Correct |
2 ms |
824 KB |
Output is correct |
10 |
Correct |
2 ms |
824 KB |
Output is correct |
11 |
Correct |
2 ms |
824 KB |
Output is correct |
12 |
Correct |
2 ms |
824 KB |
Output is correct |
13 |
Correct |
2 ms |
824 KB |
Output is correct |
14 |
Correct |
1 ms |
824 KB |
Output is correct |
15 |
Incorrect |
1 ms |
824 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
824 KB |
Output is correct |
2 |
Correct |
2 ms |
824 KB |
Output is correct |
3 |
Correct |
1 ms |
824 KB |
Output is correct |
4 |
Correct |
2 ms |
824 KB |
Output is correct |
5 |
Correct |
2 ms |
824 KB |
Output is correct |
6 |
Correct |
3 ms |
824 KB |
Output is correct |
7 |
Correct |
2 ms |
824 KB |
Output is correct |
8 |
Correct |
2 ms |
824 KB |
Output is correct |
9 |
Correct |
2 ms |
824 KB |
Output is correct |
10 |
Correct |
3 ms |
824 KB |
Output is correct |
11 |
Correct |
3 ms |
824 KB |
Output is correct |
12 |
Correct |
2 ms |
824 KB |
Output is correct |
13 |
Correct |
3 ms |
824 KB |
Output is correct |
14 |
Correct |
2 ms |
824 KB |
Output is correct |
15 |
Correct |
3 ms |
824 KB |
Output is correct |
16 |
Correct |
5 ms |
876 KB |
Output is correct |
17 |
Correct |
5 ms |
1004 KB |
Output is correct |
18 |
Correct |
6 ms |
1008 KB |
Output is correct |
19 |
Correct |
6 ms |
1008 KB |
Output is correct |
20 |
Correct |
6 ms |
1008 KB |
Output is correct |
21 |
Correct |
6 ms |
1008 KB |
Output is correct |
22 |
Correct |
6 ms |
1116 KB |
Output is correct |
23 |
Correct |
6 ms |
1116 KB |
Output is correct |
24 |
Correct |
7 ms |
1116 KB |
Output is correct |
25 |
Correct |
9 ms |
1132 KB |
Output is correct |
26 |
Correct |
13 ms |
1132 KB |
Output is correct |
27 |
Correct |
15 ms |
1260 KB |
Output is correct |
28 |
Correct |
19 ms |
1388 KB |
Output is correct |
29 |
Correct |
19 ms |
1388 KB |
Output is correct |
30 |
Correct |
18 ms |
1388 KB |
Output is correct |
31 |
Correct |
18 ms |
1388 KB |
Output is correct |
32 |
Correct |
19 ms |
1388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1388 KB |
Output is correct |
2 |
Correct |
1 ms |
1388 KB |
Output is correct |
3 |
Correct |
1 ms |
1388 KB |
Output is correct |
4 |
Correct |
1 ms |
1388 KB |
Output is correct |
5 |
Correct |
2 ms |
1388 KB |
Output is correct |
6 |
Correct |
2 ms |
1388 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
2 ms |
1388 KB |
Output is correct |
9 |
Correct |
2 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
1388 KB |
Output is correct |
11 |
Correct |
2 ms |
1388 KB |
Output is correct |
12 |
Correct |
2 ms |
1388 KB |
Output is correct |
13 |
Correct |
2 ms |
1388 KB |
Output is correct |
14 |
Correct |
1 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
2 ms |
1388 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1388 KB |
Output is correct |
2 |
Correct |
2 ms |
1388 KB |
Output is correct |
3 |
Correct |
2 ms |
1388 KB |
Output is correct |
4 |
Correct |
2 ms |
1388 KB |
Output is correct |
5 |
Correct |
2 ms |
1388 KB |
Output is correct |
6 |
Correct |
2 ms |
1388 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
2 ms |
1388 KB |
Output is correct |
9 |
Correct |
2 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
1388 KB |
Output is correct |
11 |
Correct |
2 ms |
1388 KB |
Output is correct |
12 |
Correct |
2 ms |
1388 KB |
Output is correct |
13 |
Correct |
2 ms |
1388 KB |
Output is correct |
14 |
Runtime error |
2 ms |
1388 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |