#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = (int)2e3+10;
const int LINF = (int)1e18;
int n, A, B;
int a[maxn];
int dp[maxn][maxn];
int recur(int pos, int k, int tot, int Or){
if(k>B) return LINF;
if(pos==n){
if(k<A or k>B) return LINF;
return Or|tot;
}
int x1 = recur(pos+1,k,tot+a[pos],Or);
int x2 = recur(pos+1,k+1,a[pos],Or|tot);
return dp[pos][k] = min(x1,x2);
}
int32_t main() {
cin >> n >> A >> B; memset(dp,-1,sizeof(dp));
for(int i = 0; i < n; i++) cin >> a[i];
cout << recur(0,1,0,0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31828 KB |
Output is correct |
2 |
Correct |
15 ms |
31868 KB |
Output is correct |
3 |
Correct |
12 ms |
31828 KB |
Output is correct |
4 |
Correct |
12 ms |
31896 KB |
Output is correct |
5 |
Correct |
12 ms |
31828 KB |
Output is correct |
6 |
Correct |
11 ms |
31868 KB |
Output is correct |
7 |
Correct |
13 ms |
31828 KB |
Output is correct |
8 |
Correct |
12 ms |
31924 KB |
Output is correct |
9 |
Correct |
13 ms |
31892 KB |
Output is correct |
10 |
Correct |
12 ms |
31920 KB |
Output is correct |
11 |
Correct |
14 ms |
31828 KB |
Output is correct |
12 |
Correct |
13 ms |
31908 KB |
Output is correct |
13 |
Correct |
21 ms |
31924 KB |
Output is correct |
14 |
Correct |
14 ms |
31924 KB |
Output is correct |
15 |
Incorrect |
15 ms |
31828 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
31828 KB |
Output is correct |
2 |
Correct |
15 ms |
31956 KB |
Output is correct |
3 |
Correct |
12 ms |
31828 KB |
Output is correct |
4 |
Correct |
13 ms |
31900 KB |
Output is correct |
5 |
Correct |
12 ms |
31912 KB |
Output is correct |
6 |
Correct |
13 ms |
31828 KB |
Output is correct |
7 |
Correct |
13 ms |
31828 KB |
Output is correct |
8 |
Correct |
13 ms |
31828 KB |
Output is correct |
9 |
Correct |
15 ms |
31828 KB |
Output is correct |
10 |
Correct |
14 ms |
31888 KB |
Output is correct |
11 |
Correct |
13 ms |
31828 KB |
Output is correct |
12 |
Correct |
13 ms |
31920 KB |
Output is correct |
13 |
Correct |
20 ms |
31908 KB |
Output is correct |
14 |
Correct |
13 ms |
31812 KB |
Output is correct |
15 |
Incorrect |
13 ms |
31828 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31828 KB |
Output is correct |
2 |
Correct |
13 ms |
31864 KB |
Output is correct |
3 |
Correct |
13 ms |
31828 KB |
Output is correct |
4 |
Correct |
13 ms |
31828 KB |
Output is correct |
5 |
Correct |
13 ms |
31808 KB |
Output is correct |
6 |
Correct |
13 ms |
31828 KB |
Output is correct |
7 |
Correct |
15 ms |
31828 KB |
Output is correct |
8 |
Correct |
13 ms |
31924 KB |
Output is correct |
9 |
Correct |
14 ms |
31828 KB |
Output is correct |
10 |
Correct |
13 ms |
31828 KB |
Output is correct |
11 |
Correct |
13 ms |
31828 KB |
Output is correct |
12 |
Correct |
13 ms |
31928 KB |
Output is correct |
13 |
Correct |
22 ms |
31924 KB |
Output is correct |
14 |
Correct |
32 ms |
31916 KB |
Output is correct |
15 |
Correct |
66 ms |
31912 KB |
Output is correct |
16 |
Correct |
17 ms |
31924 KB |
Output is correct |
17 |
Execution timed out |
1090 ms |
31920 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
31828 KB |
Output is correct |
2 |
Correct |
13 ms |
31828 KB |
Output is correct |
3 |
Correct |
14 ms |
31832 KB |
Output is correct |
4 |
Correct |
13 ms |
31828 KB |
Output is correct |
5 |
Correct |
14 ms |
31896 KB |
Output is correct |
6 |
Correct |
12 ms |
31900 KB |
Output is correct |
7 |
Correct |
16 ms |
31932 KB |
Output is correct |
8 |
Correct |
13 ms |
31828 KB |
Output is correct |
9 |
Correct |
13 ms |
31868 KB |
Output is correct |
10 |
Correct |
13 ms |
31924 KB |
Output is correct |
11 |
Correct |
14 ms |
31924 KB |
Output is correct |
12 |
Correct |
13 ms |
31924 KB |
Output is correct |
13 |
Correct |
21 ms |
31824 KB |
Output is correct |
14 |
Correct |
13 ms |
31924 KB |
Output is correct |
15 |
Incorrect |
13 ms |
31828 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
31916 KB |
Output is correct |
2 |
Correct |
12 ms |
31828 KB |
Output is correct |
3 |
Correct |
12 ms |
31828 KB |
Output is correct |
4 |
Correct |
13 ms |
31864 KB |
Output is correct |
5 |
Correct |
13 ms |
31828 KB |
Output is correct |
6 |
Correct |
13 ms |
31868 KB |
Output is correct |
7 |
Correct |
12 ms |
31828 KB |
Output is correct |
8 |
Correct |
13 ms |
31824 KB |
Output is correct |
9 |
Correct |
14 ms |
31928 KB |
Output is correct |
10 |
Correct |
13 ms |
31920 KB |
Output is correct |
11 |
Correct |
13 ms |
31828 KB |
Output is correct |
12 |
Correct |
13 ms |
31828 KB |
Output is correct |
13 |
Correct |
22 ms |
31812 KB |
Output is correct |
14 |
Correct |
13 ms |
31828 KB |
Output is correct |
15 |
Correct |
14 ms |
31872 KB |
Output is correct |
16 |
Correct |
13 ms |
31916 KB |
Output is correct |
17 |
Correct |
14 ms |
31828 KB |
Output is correct |
18 |
Correct |
15 ms |
31928 KB |
Output is correct |
19 |
Correct |
13 ms |
31868 KB |
Output is correct |
20 |
Correct |
21 ms |
31920 KB |
Output is correct |
21 |
Correct |
23 ms |
31880 KB |
Output is correct |
22 |
Correct |
13 ms |
31828 KB |
Output is correct |
23 |
Correct |
21 ms |
31828 KB |
Output is correct |
24 |
Correct |
30 ms |
31856 KB |
Output is correct |
25 |
Correct |
63 ms |
31908 KB |
Output is correct |
26 |
Correct |
16 ms |
31932 KB |
Output is correct |
27 |
Execution timed out |
1093 ms |
31836 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |