#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
vector<ll> v;
int n;
const int N=500;
ll pre[N];
ll dp[N][N];
ll query(int l,int r){
return pre[r]-pre[l-1];
}
ll solve(int idx,int k){
if(k<0) return 1e18;
if(idx==n+1) {
if(k==0) {
return 0;
}
return 1e18;
}
if(dp[idx][k]!=-1) return dp[idx][k];
ll ans=1e18;
for(int j=idx; j<=n; j++) {
ans=min(ans,query(idx,j) | solve(j+1,k-1));
}
return dp[idx][k]=ans;
}
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
cin>>n;
int a,b;
cin>>a>>b;
v.resize(n+1);
for(int i=1; i<=n; i++) {
cin>>v[i];
pre[i]=pre[i-1]+v[i];
}
ll ans=1e18;
for(int i=a; i<=b; i++) {
memset(dp,-1,sizeof dp);
ans=min(ans,solve(1,i));
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2304 KB |
Output is correct |
2 |
Correct |
3 ms |
2304 KB |
Output is correct |
3 |
Correct |
3 ms |
2304 KB |
Output is correct |
4 |
Correct |
9 ms |
2304 KB |
Output is correct |
5 |
Correct |
3 ms |
2304 KB |
Output is correct |
6 |
Correct |
5 ms |
2304 KB |
Output is correct |
7 |
Correct |
3 ms |
2304 KB |
Output is correct |
8 |
Correct |
3 ms |
2304 KB |
Output is correct |
9 |
Correct |
3 ms |
2304 KB |
Output is correct |
10 |
Correct |
4 ms |
2304 KB |
Output is correct |
11 |
Correct |
3 ms |
2304 KB |
Output is correct |
12 |
Correct |
4 ms |
2276 KB |
Output is correct |
13 |
Correct |
4 ms |
2304 KB |
Output is correct |
14 |
Correct |
4 ms |
2304 KB |
Output is correct |
15 |
Correct |
3 ms |
2304 KB |
Output is correct |
16 |
Correct |
3 ms |
2304 KB |
Output is correct |
17 |
Correct |
3 ms |
2304 KB |
Output is correct |
18 |
Correct |
4 ms |
2560 KB |
Output is correct |
19 |
Correct |
3 ms |
2304 KB |
Output is correct |
20 |
Correct |
3 ms |
2304 KB |
Output is correct |
21 |
Incorrect |
3 ms |
2304 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2304 KB |
Output is correct |
2 |
Correct |
4 ms |
2304 KB |
Output is correct |
3 |
Correct |
4 ms |
2304 KB |
Output is correct |
4 |
Correct |
4 ms |
2304 KB |
Output is correct |
5 |
Correct |
4 ms |
2304 KB |
Output is correct |
6 |
Correct |
5 ms |
2304 KB |
Output is correct |
7 |
Correct |
4 ms |
2304 KB |
Output is correct |
8 |
Correct |
4 ms |
2304 KB |
Output is correct |
9 |
Correct |
4 ms |
2304 KB |
Output is correct |
10 |
Correct |
4 ms |
2304 KB |
Output is correct |
11 |
Correct |
4 ms |
2304 KB |
Output is correct |
12 |
Correct |
3 ms |
2304 KB |
Output is correct |
13 |
Correct |
5 ms |
2304 KB |
Output is correct |
14 |
Correct |
3 ms |
2304 KB |
Output is correct |
15 |
Correct |
3 ms |
2304 KB |
Output is correct |
16 |
Correct |
9 ms |
2304 KB |
Output is correct |
17 |
Correct |
3 ms |
2304 KB |
Output is correct |
18 |
Correct |
5 ms |
2304 KB |
Output is correct |
19 |
Correct |
4 ms |
2304 KB |
Output is correct |
20 |
Correct |
4 ms |
2304 KB |
Output is correct |
21 |
Incorrect |
6 ms |
2304 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2304 KB |
Output is correct |
2 |
Correct |
4 ms |
2304 KB |
Output is correct |
3 |
Correct |
3 ms |
2304 KB |
Output is correct |
4 |
Correct |
4 ms |
2304 KB |
Output is correct |
5 |
Correct |
3 ms |
2304 KB |
Output is correct |
6 |
Correct |
5 ms |
2304 KB |
Output is correct |
7 |
Correct |
5 ms |
2304 KB |
Output is correct |
8 |
Correct |
4 ms |
2304 KB |
Output is correct |
9 |
Correct |
6 ms |
2304 KB |
Output is correct |
10 |
Correct |
11 ms |
2304 KB |
Output is correct |
11 |
Correct |
3 ms |
2304 KB |
Output is correct |
12 |
Correct |
3 ms |
2304 KB |
Output is correct |
13 |
Correct |
5 ms |
2304 KB |
Output is correct |
14 |
Correct |
5 ms |
2304 KB |
Output is correct |
15 |
Correct |
4 ms |
2304 KB |
Output is correct |
16 |
Correct |
3 ms |
2304 KB |
Output is correct |
17 |
Correct |
6 ms |
2304 KB |
Output is correct |
18 |
Correct |
6 ms |
2304 KB |
Output is correct |
19 |
Correct |
7 ms |
2304 KB |
Output is correct |
20 |
Correct |
4 ms |
2304 KB |
Output is correct |
21 |
Correct |
6 ms |
2348 KB |
Output is correct |
22 |
Correct |
5 ms |
2304 KB |
Output is correct |
23 |
Correct |
4 ms |
2304 KB |
Output is correct |
24 |
Correct |
6 ms |
2304 KB |
Output is correct |
25 |
Correct |
5 ms |
2304 KB |
Output is correct |
26 |
Correct |
9 ms |
2304 KB |
Output is correct |
27 |
Correct |
28 ms |
2304 KB |
Output is correct |
28 |
Correct |
72 ms |
2424 KB |
Output is correct |
29 |
Correct |
71 ms |
2424 KB |
Output is correct |
30 |
Correct |
3 ms |
2304 KB |
Output is correct |
31 |
Correct |
27 ms |
2336 KB |
Output is correct |
32 |
Correct |
55 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2304 KB |
Output is correct |
2 |
Correct |
4 ms |
2304 KB |
Output is correct |
3 |
Correct |
4 ms |
2304 KB |
Output is correct |
4 |
Correct |
3 ms |
2304 KB |
Output is correct |
5 |
Correct |
3 ms |
2304 KB |
Output is correct |
6 |
Correct |
5 ms |
2304 KB |
Output is correct |
7 |
Correct |
3 ms |
2304 KB |
Output is correct |
8 |
Correct |
3 ms |
2304 KB |
Output is correct |
9 |
Correct |
4 ms |
2304 KB |
Output is correct |
10 |
Correct |
4 ms |
2304 KB |
Output is correct |
11 |
Correct |
4 ms |
2304 KB |
Output is correct |
12 |
Correct |
4 ms |
2304 KB |
Output is correct |
13 |
Correct |
5 ms |
2304 KB |
Output is correct |
14 |
Correct |
3 ms |
2304 KB |
Output is correct |
15 |
Correct |
3 ms |
2304 KB |
Output is correct |
16 |
Correct |
3 ms |
2304 KB |
Output is correct |
17 |
Correct |
4 ms |
2304 KB |
Output is correct |
18 |
Correct |
3 ms |
2304 KB |
Output is correct |
19 |
Correct |
3 ms |
2304 KB |
Output is correct |
20 |
Correct |
5 ms |
2304 KB |
Output is correct |
21 |
Incorrect |
3 ms |
2304 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2304 KB |
Output is correct |
2 |
Correct |
3 ms |
2304 KB |
Output is correct |
3 |
Correct |
3 ms |
2304 KB |
Output is correct |
4 |
Correct |
3 ms |
2304 KB |
Output is correct |
5 |
Correct |
3 ms |
2304 KB |
Output is correct |
6 |
Correct |
5 ms |
2304 KB |
Output is correct |
7 |
Correct |
3 ms |
2304 KB |
Output is correct |
8 |
Correct |
4 ms |
2304 KB |
Output is correct |
9 |
Correct |
4 ms |
2304 KB |
Output is correct |
10 |
Correct |
4 ms |
2304 KB |
Output is correct |
11 |
Correct |
3 ms |
2304 KB |
Output is correct |
12 |
Correct |
4 ms |
2304 KB |
Output is correct |
13 |
Correct |
5 ms |
2304 KB |
Output is correct |
14 |
Correct |
3 ms |
2304 KB |
Output is correct |
15 |
Correct |
3 ms |
2304 KB |
Output is correct |
16 |
Correct |
4 ms |
2304 KB |
Output is correct |
17 |
Correct |
3 ms |
2304 KB |
Output is correct |
18 |
Correct |
4 ms |
2304 KB |
Output is correct |
19 |
Correct |
3 ms |
2304 KB |
Output is correct |
20 |
Correct |
4 ms |
2304 KB |
Output is correct |
21 |
Correct |
5 ms |
2304 KB |
Output is correct |
22 |
Correct |
6 ms |
2304 KB |
Output is correct |
23 |
Correct |
6 ms |
2348 KB |
Output is correct |
24 |
Correct |
5 ms |
2304 KB |
Output is correct |
25 |
Correct |
4 ms |
2276 KB |
Output is correct |
26 |
Correct |
4 ms |
2304 KB |
Output is correct |
27 |
Correct |
6 ms |
2304 KB |
Output is correct |
28 |
Correct |
13 ms |
2276 KB |
Output is correct |
29 |
Correct |
6 ms |
2304 KB |
Output is correct |
30 |
Correct |
3 ms |
2304 KB |
Output is correct |
31 |
Correct |
6 ms |
2304 KB |
Output is correct |
32 |
Correct |
8 ms |
2304 KB |
Output is correct |
33 |
Correct |
4 ms |
2352 KB |
Output is correct |
34 |
Correct |
7 ms |
2304 KB |
Output is correct |
35 |
Correct |
5 ms |
2304 KB |
Output is correct |
36 |
Correct |
9 ms |
2304 KB |
Output is correct |
37 |
Correct |
29 ms |
2372 KB |
Output is correct |
38 |
Correct |
71 ms |
2304 KB |
Output is correct |
39 |
Correct |
74 ms |
2332 KB |
Output is correct |
40 |
Correct |
4 ms |
2304 KB |
Output is correct |
41 |
Correct |
27 ms |
2304 KB |
Output is correct |
42 |
Correct |
51 ms |
2424 KB |
Output is correct |
43 |
Incorrect |
6 ms |
2304 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |