#include <bits/stdc++.h>
using namespace std;
int n,a,b;
int arr[55];
int dp[55][600][22];
int ans = 100000009;;
int bt(int id,int curr,int k){
if(id == n){
if(k >= a && k <= b){
if(curr == 9)cout<<k<<endl;
ans = min(ans,curr);
return 1;
}
else return 0;
}
int &ret = dp[id][curr][k];
if(ret != -1)return ret;
ret = 0;
int sum = 0;
for(int i=id;i<n;i++){
sum += arr[i];
ret = max(ret,bt(i+1,curr|sum,k+1));
}
return ret;
}
int main(){
memset(dp,-1,sizeof(dp));
cin>>n>>a>>b;
for(int i=0;i<n;i++){
cin>>arr[i];
}
bt(0,0,0);
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3200 KB |
Output is correct |
2 |
Correct |
4 ms |
3200 KB |
Output is correct |
3 |
Correct |
5 ms |
3236 KB |
Output is correct |
4 |
Correct |
4 ms |
3200 KB |
Output is correct |
5 |
Correct |
5 ms |
3200 KB |
Output is correct |
6 |
Correct |
4 ms |
3200 KB |
Output is correct |
7 |
Correct |
4 ms |
3200 KB |
Output is correct |
8 |
Correct |
5 ms |
3200 KB |
Output is correct |
9 |
Correct |
4 ms |
3200 KB |
Output is correct |
10 |
Correct |
4 ms |
3200 KB |
Output is correct |
11 |
Correct |
5 ms |
3200 KB |
Output is correct |
12 |
Correct |
4 ms |
3200 KB |
Output is correct |
13 |
Correct |
5 ms |
3200 KB |
Output is correct |
14 |
Correct |
5 ms |
3200 KB |
Output is correct |
15 |
Correct |
7 ms |
3200 KB |
Output is correct |
16 |
Correct |
5 ms |
3200 KB |
Output is correct |
17 |
Correct |
4 ms |
3200 KB |
Output is correct |
18 |
Correct |
5 ms |
3200 KB |
Output is correct |
19 |
Correct |
4 ms |
3200 KB |
Output is correct |
20 |
Correct |
5 ms |
3200 KB |
Output is correct |
21 |
Correct |
5 ms |
3200 KB |
Output is correct |
22 |
Correct |
5 ms |
3200 KB |
Output is correct |
23 |
Correct |
5 ms |
3200 KB |
Output is correct |
24 |
Correct |
4 ms |
3200 KB |
Output is correct |
25 |
Correct |
4 ms |
3200 KB |
Output is correct |
26 |
Correct |
4 ms |
3200 KB |
Output is correct |
27 |
Runtime error |
8 ms |
6144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3200 KB |
Output is correct |
2 |
Correct |
4 ms |
3200 KB |
Output is correct |
3 |
Correct |
5 ms |
3172 KB |
Output is correct |
4 |
Correct |
6 ms |
3200 KB |
Output is correct |
5 |
Correct |
5 ms |
3200 KB |
Output is correct |
6 |
Correct |
5 ms |
3200 KB |
Output is correct |
7 |
Correct |
5 ms |
3200 KB |
Output is correct |
8 |
Correct |
6 ms |
3200 KB |
Output is correct |
9 |
Correct |
4 ms |
3200 KB |
Output is correct |
10 |
Correct |
5 ms |
3200 KB |
Output is correct |
11 |
Correct |
4 ms |
3200 KB |
Output is correct |
12 |
Correct |
4 ms |
3200 KB |
Output is correct |
13 |
Correct |
4 ms |
3200 KB |
Output is correct |
14 |
Correct |
5 ms |
3200 KB |
Output is correct |
15 |
Correct |
6 ms |
3200 KB |
Output is correct |
16 |
Correct |
5 ms |
3200 KB |
Output is correct |
17 |
Correct |
4 ms |
3200 KB |
Output is correct |
18 |
Correct |
5 ms |
3200 KB |
Output is correct |
19 |
Correct |
5 ms |
3200 KB |
Output is correct |
20 |
Correct |
5 ms |
3200 KB |
Output is correct |
21 |
Correct |
5 ms |
3132 KB |
Output is correct |
22 |
Correct |
6 ms |
3200 KB |
Output is correct |
23 |
Correct |
5 ms |
3200 KB |
Output is correct |
24 |
Correct |
5 ms |
3200 KB |
Output is correct |
25 |
Correct |
3 ms |
3200 KB |
Output is correct |
26 |
Correct |
5 ms |
3200 KB |
Output is correct |
27 |
Correct |
5 ms |
3200 KB |
Output is correct |
28 |
Correct |
5 ms |
3200 KB |
Output is correct |
29 |
Correct |
6 ms |
3200 KB |
Output is correct |
30 |
Correct |
7 ms |
3200 KB |
Output is correct |
31 |
Correct |
8 ms |
3100 KB |
Output is correct |
32 |
Correct |
5 ms |
3200 KB |
Output is correct |
33 |
Correct |
6 ms |
3200 KB |
Output is correct |
34 |
Correct |
6 ms |
3200 KB |
Output is correct |
35 |
Correct |
7 ms |
3200 KB |
Output is correct |
36 |
Correct |
7 ms |
3200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3200 KB |
Output is correct |
2 |
Correct |
5 ms |
3200 KB |
Output is correct |
3 |
Correct |
5 ms |
3200 KB |
Output is correct |
4 |
Correct |
4 ms |
3200 KB |
Output is correct |
5 |
Correct |
4 ms |
3200 KB |
Output is correct |
6 |
Correct |
4 ms |
3200 KB |
Output is correct |
7 |
Correct |
4 ms |
3200 KB |
Output is correct |
8 |
Correct |
4 ms |
3200 KB |
Output is correct |
9 |
Correct |
5 ms |
3200 KB |
Output is correct |
10 |
Correct |
5 ms |
3200 KB |
Output is correct |
11 |
Correct |
4 ms |
3200 KB |
Output is correct |
12 |
Correct |
5 ms |
3200 KB |
Output is correct |
13 |
Correct |
4 ms |
3200 KB |
Output is correct |
14 |
Correct |
5 ms |
3200 KB |
Output is correct |
15 |
Correct |
4 ms |
3200 KB |
Output is correct |
16 |
Correct |
6 ms |
3200 KB |
Output is correct |
17 |
Correct |
5 ms |
3200 KB |
Output is correct |
18 |
Correct |
7 ms |
3200 KB |
Output is correct |
19 |
Correct |
6 ms |
3200 KB |
Output is correct |
20 |
Correct |
8 ms |
3200 KB |
Output is correct |
21 |
Correct |
6 ms |
3200 KB |
Output is correct |
22 |
Correct |
7 ms |
3200 KB |
Output is correct |
23 |
Correct |
9 ms |
3200 KB |
Output is correct |
24 |
Correct |
7 ms |
3200 KB |
Output is correct |
25 |
Incorrect |
5 ms |
3200 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3200 KB |
Output is correct |
2 |
Correct |
4 ms |
3200 KB |
Output is correct |
3 |
Correct |
4 ms |
3200 KB |
Output is correct |
4 |
Correct |
5 ms |
3200 KB |
Output is correct |
5 |
Correct |
5 ms |
3200 KB |
Output is correct |
6 |
Correct |
4 ms |
3200 KB |
Output is correct |
7 |
Correct |
5 ms |
3200 KB |
Output is correct |
8 |
Correct |
5 ms |
3200 KB |
Output is correct |
9 |
Correct |
4 ms |
3200 KB |
Output is correct |
10 |
Correct |
4 ms |
3224 KB |
Output is correct |
11 |
Correct |
4 ms |
3200 KB |
Output is correct |
12 |
Correct |
4 ms |
3200 KB |
Output is correct |
13 |
Correct |
5 ms |
3200 KB |
Output is correct |
14 |
Correct |
5 ms |
3172 KB |
Output is correct |
15 |
Correct |
5 ms |
3200 KB |
Output is correct |
16 |
Correct |
6 ms |
3200 KB |
Output is correct |
17 |
Correct |
5 ms |
3200 KB |
Output is correct |
18 |
Correct |
5 ms |
3200 KB |
Output is correct |
19 |
Correct |
6 ms |
3200 KB |
Output is correct |
20 |
Correct |
4 ms |
3200 KB |
Output is correct |
21 |
Correct |
5 ms |
3200 KB |
Output is correct |
22 |
Correct |
6 ms |
3200 KB |
Output is correct |
23 |
Correct |
6 ms |
3200 KB |
Output is correct |
24 |
Correct |
5 ms |
3200 KB |
Output is correct |
25 |
Correct |
6 ms |
3276 KB |
Output is correct |
26 |
Correct |
5 ms |
3200 KB |
Output is correct |
27 |
Runtime error |
10 ms |
6144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3200 KB |
Output is correct |
2 |
Correct |
4 ms |
3200 KB |
Output is correct |
3 |
Correct |
5 ms |
3200 KB |
Output is correct |
4 |
Correct |
5 ms |
3236 KB |
Output is correct |
5 |
Correct |
4 ms |
3200 KB |
Output is correct |
6 |
Correct |
6 ms |
3200 KB |
Output is correct |
7 |
Correct |
5 ms |
3200 KB |
Output is correct |
8 |
Correct |
5 ms |
3200 KB |
Output is correct |
9 |
Correct |
4 ms |
3200 KB |
Output is correct |
10 |
Correct |
5 ms |
3200 KB |
Output is correct |
11 |
Correct |
4 ms |
3200 KB |
Output is correct |
12 |
Correct |
4 ms |
3200 KB |
Output is correct |
13 |
Correct |
4 ms |
3200 KB |
Output is correct |
14 |
Runtime error |
9 ms |
6144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Halted |
0 ms |
0 KB |
- |