#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define endl '\n'
#define bit __builtin_popcount
typedef long long int ll;
const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9 + 5;
const int P = 31;
const int ALP = 22;
const int N = 1e3 + 5;
const int M = 26;
const int SQ = 350;
const int MOD = 1e9 + 7;
typedef long long int lli;
typedef pair<int,int> pii;
int n,x,y,a[N];
ll dp[N][N];
ll f(int cur,int par) {
if (par > y) return LINF;
if (cur == n + 1) {
if (par >= x) return 0;
return LINF;
}
ll &r = dp[cur][par];
if (r != -1) return r;
ll sum = 0;
r = LINF;
for (int i = cur; i <= n ; i++) {
sum += a[i];
r = min(r,sum | f(i + 1,par + 1));
}
return r;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> x >> y;
for (int i = 1 ; i <= n ; i++)
cin >> a[i];
memset(dp,-1,sizeof dp);
cout << f(1,0) << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8184 KB |
Output is correct |
2 |
Correct |
8 ms |
8308 KB |
Output is correct |
3 |
Correct |
8 ms |
8328 KB |
Output is correct |
4 |
Correct |
8 ms |
8404 KB |
Output is correct |
5 |
Correct |
8 ms |
8412 KB |
Output is correct |
6 |
Correct |
8 ms |
8412 KB |
Output is correct |
7 |
Correct |
8 ms |
8508 KB |
Output is correct |
8 |
Correct |
8 ms |
8508 KB |
Output is correct |
9 |
Correct |
8 ms |
8524 KB |
Output is correct |
10 |
Correct |
8 ms |
8524 KB |
Output is correct |
11 |
Correct |
9 ms |
8524 KB |
Output is correct |
12 |
Correct |
8 ms |
8524 KB |
Output is correct |
13 |
Correct |
8 ms |
8540 KB |
Output is correct |
14 |
Correct |
8 ms |
8560 KB |
Output is correct |
15 |
Correct |
8 ms |
8588 KB |
Output is correct |
16 |
Correct |
8 ms |
8588 KB |
Output is correct |
17 |
Correct |
8 ms |
8588 KB |
Output is correct |
18 |
Correct |
9 ms |
8588 KB |
Output is correct |
19 |
Correct |
8 ms |
8588 KB |
Output is correct |
20 |
Correct |
8 ms |
8588 KB |
Output is correct |
21 |
Incorrect |
8 ms |
8588 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8588 KB |
Output is correct |
2 |
Correct |
8 ms |
8588 KB |
Output is correct |
3 |
Correct |
8 ms |
8588 KB |
Output is correct |
4 |
Correct |
8 ms |
8588 KB |
Output is correct |
5 |
Correct |
8 ms |
8588 KB |
Output is correct |
6 |
Correct |
8 ms |
8588 KB |
Output is correct |
7 |
Correct |
9 ms |
8588 KB |
Output is correct |
8 |
Correct |
8 ms |
8588 KB |
Output is correct |
9 |
Correct |
8 ms |
8588 KB |
Output is correct |
10 |
Correct |
11 ms |
8588 KB |
Output is correct |
11 |
Correct |
8 ms |
8588 KB |
Output is correct |
12 |
Correct |
8 ms |
8588 KB |
Output is correct |
13 |
Correct |
10 ms |
8588 KB |
Output is correct |
14 |
Correct |
9 ms |
8588 KB |
Output is correct |
15 |
Correct |
8 ms |
8664 KB |
Output is correct |
16 |
Correct |
8 ms |
8664 KB |
Output is correct |
17 |
Correct |
8 ms |
8664 KB |
Output is correct |
18 |
Correct |
8 ms |
8664 KB |
Output is correct |
19 |
Correct |
8 ms |
8664 KB |
Output is correct |
20 |
Correct |
8 ms |
8664 KB |
Output is correct |
21 |
Incorrect |
8 ms |
8664 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8664 KB |
Output is correct |
2 |
Correct |
8 ms |
8664 KB |
Output is correct |
3 |
Correct |
8 ms |
8664 KB |
Output is correct |
4 |
Correct |
8 ms |
8664 KB |
Output is correct |
5 |
Correct |
8 ms |
8664 KB |
Output is correct |
6 |
Correct |
9 ms |
8664 KB |
Output is correct |
7 |
Correct |
9 ms |
8664 KB |
Output is correct |
8 |
Correct |
9 ms |
8696 KB |
Output is correct |
9 |
Correct |
9 ms |
8700 KB |
Output is correct |
10 |
Correct |
8 ms |
8700 KB |
Output is correct |
11 |
Correct |
8 ms |
8700 KB |
Output is correct |
12 |
Correct |
8 ms |
8700 KB |
Output is correct |
13 |
Correct |
8 ms |
8700 KB |
Output is correct |
14 |
Correct |
8 ms |
8700 KB |
Output is correct |
15 |
Correct |
8 ms |
8700 KB |
Output is correct |
16 |
Correct |
8 ms |
8700 KB |
Output is correct |
17 |
Correct |
8 ms |
8700 KB |
Output is correct |
18 |
Correct |
8 ms |
8700 KB |
Output is correct |
19 |
Correct |
8 ms |
8700 KB |
Output is correct |
20 |
Correct |
9 ms |
8700 KB |
Output is correct |
21 |
Correct |
9 ms |
8700 KB |
Output is correct |
22 |
Correct |
8 ms |
8700 KB |
Output is correct |
23 |
Correct |
8 ms |
8700 KB |
Output is correct |
24 |
Correct |
8 ms |
8700 KB |
Output is correct |
25 |
Correct |
8 ms |
8700 KB |
Output is correct |
26 |
Correct |
8 ms |
8700 KB |
Output is correct |
27 |
Correct |
10 ms |
8700 KB |
Output is correct |
28 |
Correct |
10 ms |
8700 KB |
Output is correct |
29 |
Correct |
10 ms |
8700 KB |
Output is correct |
30 |
Correct |
8 ms |
8700 KB |
Output is correct |
31 |
Correct |
10 ms |
8700 KB |
Output is correct |
32 |
Correct |
9 ms |
8700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8700 KB |
Output is correct |
2 |
Correct |
8 ms |
8700 KB |
Output is correct |
3 |
Correct |
8 ms |
8700 KB |
Output is correct |
4 |
Correct |
8 ms |
8700 KB |
Output is correct |
5 |
Correct |
8 ms |
8700 KB |
Output is correct |
6 |
Correct |
8 ms |
8700 KB |
Output is correct |
7 |
Correct |
8 ms |
8700 KB |
Output is correct |
8 |
Correct |
8 ms |
8700 KB |
Output is correct |
9 |
Correct |
8 ms |
8700 KB |
Output is correct |
10 |
Correct |
8 ms |
8700 KB |
Output is correct |
11 |
Correct |
8 ms |
8700 KB |
Output is correct |
12 |
Correct |
9 ms |
8700 KB |
Output is correct |
13 |
Correct |
9 ms |
8700 KB |
Output is correct |
14 |
Correct |
8 ms |
8700 KB |
Output is correct |
15 |
Correct |
8 ms |
8704 KB |
Output is correct |
16 |
Correct |
9 ms |
8704 KB |
Output is correct |
17 |
Correct |
9 ms |
8720 KB |
Output is correct |
18 |
Correct |
8 ms |
8720 KB |
Output is correct |
19 |
Correct |
8 ms |
8720 KB |
Output is correct |
20 |
Correct |
8 ms |
8724 KB |
Output is correct |
21 |
Incorrect |
8 ms |
8724 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8728 KB |
Output is correct |
2 |
Correct |
8 ms |
8728 KB |
Output is correct |
3 |
Correct |
8 ms |
8728 KB |
Output is correct |
4 |
Correct |
8 ms |
8728 KB |
Output is correct |
5 |
Correct |
8 ms |
8756 KB |
Output is correct |
6 |
Correct |
8 ms |
8756 KB |
Output is correct |
7 |
Correct |
8 ms |
8756 KB |
Output is correct |
8 |
Correct |
9 ms |
8756 KB |
Output is correct |
9 |
Correct |
8 ms |
8864 KB |
Output is correct |
10 |
Correct |
8 ms |
8864 KB |
Output is correct |
11 |
Correct |
9 ms |
8864 KB |
Output is correct |
12 |
Correct |
8 ms |
8864 KB |
Output is correct |
13 |
Correct |
8 ms |
8864 KB |
Output is correct |
14 |
Correct |
8 ms |
8864 KB |
Output is correct |
15 |
Correct |
8 ms |
8864 KB |
Output is correct |
16 |
Correct |
10 ms |
8864 KB |
Output is correct |
17 |
Correct |
10 ms |
8864 KB |
Output is correct |
18 |
Incorrect |
8 ms |
8864 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |