/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
ll n, a, b, A[N], pref[N];
set<ll> dp[105][105];
void solve(){
cin >> n >> a >> b;
for(int i = 1; i <= n; ++i) cin >> A[i];
pref[0] = 0;
for(int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + A[i];
dp[0][0].insert(0);
for(int i = 1; i <= n; ++i){
for(int j = 0; j < i; ++j){
for(int k = 1; k <= j + 1; ++k){
for(ll s: dp[j][k - 1])
dp[i][k].insert(s | (pref[i] - pref[j]));
}
}
}
ll ans = 1e18;
for(int i = a; i <= b; ++i){
if(dp[n][i].empty()) continue;
ans = min(ans, *dp[n][i].begin());
}
cout << ans;
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// cin >> tt;
while(tt--){
solve();
en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:40:15: warning: unused variable 'aa' [-Wunused-variable]
40 | int tt = 1, aa;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4708 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4712 KB |
Output is correct |
7 |
Correct |
1 ms |
4948 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
1 ms |
4732 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4696 KB |
Output is correct |
16 |
Correct |
1 ms |
4700 KB |
Output is correct |
17 |
Correct |
1 ms |
4700 KB |
Output is correct |
18 |
Correct |
1 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4696 KB |
Output is correct |
20 |
Correct |
1 ms |
4700 KB |
Output is correct |
21 |
Correct |
1 ms |
4700 KB |
Output is correct |
22 |
Correct |
1 ms |
4700 KB |
Output is correct |
23 |
Correct |
1 ms |
4700 KB |
Output is correct |
24 |
Correct |
1 ms |
4700 KB |
Output is correct |
25 |
Correct |
1 ms |
4700 KB |
Output is correct |
26 |
Correct |
1 ms |
4700 KB |
Output is correct |
27 |
Correct |
1 ms |
4700 KB |
Output is correct |
28 |
Correct |
1 ms |
4700 KB |
Output is correct |
29 |
Correct |
1 ms |
4700 KB |
Output is correct |
30 |
Correct |
3 ms |
4956 KB |
Output is correct |
31 |
Correct |
2 ms |
4700 KB |
Output is correct |
32 |
Correct |
2 ms |
4764 KB |
Output is correct |
33 |
Correct |
1 ms |
4696 KB |
Output is correct |
34 |
Correct |
1 ms |
4700 KB |
Output is correct |
35 |
Correct |
1 ms |
4700 KB |
Output is correct |
36 |
Correct |
1 ms |
4700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4700 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4700 KB |
Output is correct |
16 |
Correct |
1 ms |
4512 KB |
Output is correct |
17 |
Correct |
1 ms |
4700 KB |
Output is correct |
18 |
Correct |
1 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4700 KB |
Output is correct |
20 |
Correct |
1 ms |
4700 KB |
Output is correct |
21 |
Correct |
1 ms |
4700 KB |
Output is correct |
22 |
Correct |
2 ms |
4696 KB |
Output is correct |
23 |
Correct |
1 ms |
4700 KB |
Output is correct |
24 |
Correct |
1 ms |
4696 KB |
Output is correct |
25 |
Correct |
1 ms |
4700 KB |
Output is correct |
26 |
Correct |
1 ms |
4700 KB |
Output is correct |
27 |
Correct |
1 ms |
4724 KB |
Output is correct |
28 |
Correct |
2 ms |
4700 KB |
Output is correct |
29 |
Correct |
4 ms |
4956 KB |
Output is correct |
30 |
Correct |
6 ms |
5308 KB |
Output is correct |
31 |
Correct |
17 ms |
5980 KB |
Output is correct |
32 |
Correct |
8 ms |
5464 KB |
Output is correct |
33 |
Correct |
7 ms |
5464 KB |
Output is correct |
34 |
Correct |
10 ms |
5476 KB |
Output is correct |
35 |
Correct |
10 ms |
5464 KB |
Output is correct |
36 |
Correct |
13 ms |
5752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4700 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
1 ms |
4952 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4700 KB |
Output is correct |
16 |
Correct |
5 ms |
4956 KB |
Output is correct |
17 |
Correct |
6 ms |
5276 KB |
Output is correct |
18 |
Correct |
16 ms |
5980 KB |
Output is correct |
19 |
Correct |
8 ms |
5392 KB |
Output is correct |
20 |
Correct |
8 ms |
5352 KB |
Output is correct |
21 |
Correct |
10 ms |
5468 KB |
Output is correct |
22 |
Correct |
10 ms |
5612 KB |
Output is correct |
23 |
Correct |
13 ms |
5724 KB |
Output is correct |
24 |
Correct |
18 ms |
6116 KB |
Output is correct |
25 |
Correct |
51 ms |
7872 KB |
Output is correct |
26 |
Correct |
105 ms |
10460 KB |
Output is correct |
27 |
Correct |
167 ms |
12988 KB |
Output is correct |
28 |
Correct |
251 ms |
15956 KB |
Output is correct |
29 |
Correct |
149 ms |
11952 KB |
Output is correct |
30 |
Correct |
152 ms |
11992 KB |
Output is correct |
31 |
Correct |
282 ms |
17112 KB |
Output is correct |
32 |
Correct |
303 ms |
17232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
1 ms |
4688 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
1 ms |
4696 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4696 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4700 KB |
Output is correct |
16 |
Correct |
1 ms |
4700 KB |
Output is correct |
17 |
Correct |
1 ms |
4700 KB |
Output is correct |
18 |
Correct |
1 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4700 KB |
Output is correct |
20 |
Correct |
1 ms |
4700 KB |
Output is correct |
21 |
Correct |
1 ms |
4700 KB |
Output is correct |
22 |
Correct |
1 ms |
4700 KB |
Output is correct |
23 |
Correct |
1 ms |
4700 KB |
Output is correct |
24 |
Correct |
1 ms |
4700 KB |
Output is correct |
25 |
Correct |
1 ms |
4700 KB |
Output is correct |
26 |
Correct |
1 ms |
4696 KB |
Output is correct |
27 |
Correct |
1 ms |
4696 KB |
Output is correct |
28 |
Correct |
1 ms |
4700 KB |
Output is correct |
29 |
Correct |
1 ms |
4700 KB |
Output is correct |
30 |
Correct |
3 ms |
4956 KB |
Output is correct |
31 |
Correct |
1 ms |
4700 KB |
Output is correct |
32 |
Correct |
1 ms |
4700 KB |
Output is correct |
33 |
Correct |
1 ms |
4700 KB |
Output is correct |
34 |
Correct |
1 ms |
4700 KB |
Output is correct |
35 |
Correct |
1 ms |
4700 KB |
Output is correct |
36 |
Correct |
1 ms |
4700 KB |
Output is correct |
37 |
Correct |
1 ms |
4700 KB |
Output is correct |
38 |
Correct |
2 ms |
4700 KB |
Output is correct |
39 |
Correct |
5 ms |
4956 KB |
Output is correct |
40 |
Correct |
6 ms |
5232 KB |
Output is correct |
41 |
Correct |
17 ms |
5988 KB |
Output is correct |
42 |
Correct |
7 ms |
5468 KB |
Output is correct |
43 |
Correct |
8 ms |
5292 KB |
Output is correct |
44 |
Correct |
13 ms |
5468 KB |
Output is correct |
45 |
Correct |
11 ms |
5736 KB |
Output is correct |
46 |
Correct |
13 ms |
5724 KB |
Output is correct |
47 |
Correct |
18 ms |
6236 KB |
Output is correct |
48 |
Correct |
51 ms |
7896 KB |
Output is correct |
49 |
Correct |
103 ms |
10324 KB |
Output is correct |
50 |
Correct |
162 ms |
12908 KB |
Output is correct |
51 |
Correct |
265 ms |
15456 KB |
Output is correct |
52 |
Correct |
167 ms |
12016 KB |
Output is correct |
53 |
Correct |
150 ms |
11772 KB |
Output is correct |
54 |
Correct |
298 ms |
17340 KB |
Output is correct |
55 |
Correct |
299 ms |
17248 KB |
Output is correct |
56 |
Correct |
463 ms |
39984 KB |
Output is correct |
57 |
Execution timed out |
1061 ms |
71124 KB |
Time limit exceeded |
58 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4700 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4696 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4700 KB |
Output is correct |
16 |
Correct |
1 ms |
4700 KB |
Output is correct |
17 |
Correct |
3 ms |
4956 KB |
Output is correct |
18 |
Correct |
1 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4700 KB |
Output is correct |
20 |
Correct |
1 ms |
4700 KB |
Output is correct |
21 |
Correct |
1 ms |
4700 KB |
Output is correct |
22 |
Correct |
1 ms |
4700 KB |
Output is correct |
23 |
Correct |
1 ms |
4700 KB |
Output is correct |
24 |
Correct |
2 ms |
4700 KB |
Output is correct |
25 |
Correct |
2 ms |
4700 KB |
Output is correct |
26 |
Correct |
4 ms |
4956 KB |
Output is correct |
27 |
Correct |
7 ms |
5208 KB |
Output is correct |
28 |
Correct |
17 ms |
5980 KB |
Output is correct |
29 |
Correct |
8 ms |
5464 KB |
Output is correct |
30 |
Correct |
8 ms |
5468 KB |
Output is correct |
31 |
Correct |
10 ms |
5684 KB |
Output is correct |
32 |
Correct |
10 ms |
5468 KB |
Output is correct |
33 |
Correct |
13 ms |
5624 KB |
Output is correct |
34 |
Correct |
23 ms |
6160 KB |
Output is correct |
35 |
Correct |
57 ms |
8032 KB |
Output is correct |
36 |
Correct |
105 ms |
10452 KB |
Output is correct |
37 |
Correct |
171 ms |
12880 KB |
Output is correct |
38 |
Correct |
282 ms |
15476 KB |
Output is correct |
39 |
Correct |
178 ms |
11948 KB |
Output is correct |
40 |
Correct |
175 ms |
11968 KB |
Output is correct |
41 |
Correct |
333 ms |
17120 KB |
Output is correct |
42 |
Correct |
336 ms |
17328 KB |
Output is correct |
43 |
Correct |
506 ms |
40020 KB |
Output is correct |
44 |
Execution timed out |
1088 ms |
68304 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |