#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}
void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
_print(H);
if(sizeof...(T)) cerr<<",";
else cerr<<"\"]";
dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxn=101;
const int mxg=101;
int n,a,b;
set<ll> dp[mxn][mxg];
ll sum[mxn];
vector<ll> ar;
ll f(int l,int r) {
if(!l) return sum[r];
return sum[r]-sum[l-1];
}
int main () {
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>a>>b;
ar.resize(n);
for(int i=0;i<n;i++) cin>>ar[i];
for(int i=0;i<n;i++) {
sum[i]=ar[i];
if(i) sum[i]+=sum[i-1];
dp[i][1].insert(sum[i]);
}
for(int i=1;i<n;i++) {
for(int g=2;g<=i+1;g++) {
for(int j=i-1;j>=0;j--) {
for(auto e:dp[j][g-1]) {
dp[i][g].insert(e|f(j+1,i));
}
}
}
}
ll ans=1e16;
for(int i=a;i<=b;i++) {
if(dp[n-1][i].empty()) continue;
ans=min(ans,*dp[n-1][i].begin());
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
1 ms |
716 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
716 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
844 KB |
Output is correct |
9 |
Correct |
1 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
1 ms |
844 KB |
Output is correct |
13 |
Correct |
1 ms |
844 KB |
Output is correct |
14 |
Correct |
1 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
16 |
Correct |
1 ms |
716 KB |
Output is correct |
17 |
Correct |
1 ms |
716 KB |
Output is correct |
18 |
Correct |
1 ms |
716 KB |
Output is correct |
19 |
Correct |
2 ms |
716 KB |
Output is correct |
20 |
Correct |
1 ms |
716 KB |
Output is correct |
21 |
Correct |
1 ms |
844 KB |
Output is correct |
22 |
Correct |
2 ms |
844 KB |
Output is correct |
23 |
Correct |
2 ms |
716 KB |
Output is correct |
24 |
Correct |
2 ms |
716 KB |
Output is correct |
25 |
Correct |
1 ms |
716 KB |
Output is correct |
26 |
Correct |
2 ms |
844 KB |
Output is correct |
27 |
Correct |
1 ms |
716 KB |
Output is correct |
28 |
Correct |
1 ms |
716 KB |
Output is correct |
29 |
Correct |
2 ms |
844 KB |
Output is correct |
30 |
Correct |
5 ms |
1228 KB |
Output is correct |
31 |
Correct |
2 ms |
796 KB |
Output is correct |
32 |
Correct |
2 ms |
844 KB |
Output is correct |
33 |
Correct |
1 ms |
716 KB |
Output is correct |
34 |
Correct |
1 ms |
716 KB |
Output is correct |
35 |
Correct |
2 ms |
716 KB |
Output is correct |
36 |
Correct |
1 ms |
716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
1 ms |
716 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
716 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
864 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
844 KB |
Output is correct |
13 |
Correct |
2 ms |
844 KB |
Output is correct |
14 |
Correct |
1 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
16 |
Correct |
1 ms |
716 KB |
Output is correct |
17 |
Correct |
1 ms |
716 KB |
Output is correct |
18 |
Correct |
1 ms |
716 KB |
Output is correct |
19 |
Correct |
1 ms |
716 KB |
Output is correct |
20 |
Correct |
1 ms |
716 KB |
Output is correct |
21 |
Correct |
1 ms |
844 KB |
Output is correct |
22 |
Correct |
1 ms |
844 KB |
Output is correct |
23 |
Correct |
1 ms |
716 KB |
Output is correct |
24 |
Correct |
1 ms |
716 KB |
Output is correct |
25 |
Correct |
1 ms |
844 KB |
Output is correct |
26 |
Correct |
1 ms |
844 KB |
Output is correct |
27 |
Correct |
2 ms |
844 KB |
Output is correct |
28 |
Correct |
2 ms |
844 KB |
Output is correct |
29 |
Correct |
6 ms |
1228 KB |
Output is correct |
30 |
Correct |
8 ms |
1356 KB |
Output is correct |
31 |
Correct |
21 ms |
2124 KB |
Output is correct |
32 |
Correct |
12 ms |
1468 KB |
Output is correct |
33 |
Correct |
11 ms |
1484 KB |
Output is correct |
34 |
Correct |
13 ms |
1744 KB |
Output is correct |
35 |
Correct |
14 ms |
1684 KB |
Output is correct |
36 |
Correct |
22 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
1 ms |
716 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
2 ms |
716 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
844 KB |
Output is correct |
13 |
Correct |
1 ms |
844 KB |
Output is correct |
14 |
Correct |
1 ms |
844 KB |
Output is correct |
15 |
Correct |
3 ms |
844 KB |
Output is correct |
16 |
Correct |
7 ms |
1228 KB |
Output is correct |
17 |
Correct |
9 ms |
1384 KB |
Output is correct |
18 |
Correct |
23 ms |
2140 KB |
Output is correct |
19 |
Correct |
11 ms |
1536 KB |
Output is correct |
20 |
Correct |
10 ms |
1484 KB |
Output is correct |
21 |
Correct |
13 ms |
1740 KB |
Output is correct |
22 |
Correct |
13 ms |
1728 KB |
Output is correct |
23 |
Correct |
19 ms |
1840 KB |
Output is correct |
24 |
Correct |
25 ms |
2288 KB |
Output is correct |
25 |
Correct |
61 ms |
4124 KB |
Output is correct |
26 |
Correct |
138 ms |
6624 KB |
Output is correct |
27 |
Correct |
238 ms |
9028 KB |
Output is correct |
28 |
Correct |
292 ms |
11564 KB |
Output is correct |
29 |
Correct |
183 ms |
8004 KB |
Output is correct |
30 |
Correct |
208 ms |
8088 KB |
Output is correct |
31 |
Correct |
369 ms |
13328 KB |
Output is correct |
32 |
Correct |
367 ms |
13484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
1 ms |
716 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
716 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
1 ms |
844 KB |
Output is correct |
13 |
Correct |
1 ms |
844 KB |
Output is correct |
14 |
Correct |
2 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
16 |
Correct |
1 ms |
716 KB |
Output is correct |
17 |
Correct |
1 ms |
716 KB |
Output is correct |
18 |
Correct |
1 ms |
716 KB |
Output is correct |
19 |
Correct |
2 ms |
716 KB |
Output is correct |
20 |
Correct |
1 ms |
716 KB |
Output is correct |
21 |
Correct |
2 ms |
764 KB |
Output is correct |
22 |
Correct |
1 ms |
844 KB |
Output is correct |
23 |
Correct |
1 ms |
716 KB |
Output is correct |
24 |
Correct |
1 ms |
716 KB |
Output is correct |
25 |
Correct |
2 ms |
844 KB |
Output is correct |
26 |
Correct |
1 ms |
844 KB |
Output is correct |
27 |
Correct |
1 ms |
716 KB |
Output is correct |
28 |
Correct |
1 ms |
716 KB |
Output is correct |
29 |
Correct |
1 ms |
844 KB |
Output is correct |
30 |
Correct |
5 ms |
1100 KB |
Output is correct |
31 |
Correct |
2 ms |
800 KB |
Output is correct |
32 |
Correct |
2 ms |
844 KB |
Output is correct |
33 |
Correct |
1 ms |
716 KB |
Output is correct |
34 |
Correct |
1 ms |
716 KB |
Output is correct |
35 |
Correct |
1 ms |
796 KB |
Output is correct |
36 |
Correct |
1 ms |
716 KB |
Output is correct |
37 |
Correct |
2 ms |
844 KB |
Output is correct |
38 |
Correct |
2 ms |
844 KB |
Output is correct |
39 |
Correct |
6 ms |
1228 KB |
Output is correct |
40 |
Correct |
8 ms |
1356 KB |
Output is correct |
41 |
Correct |
21 ms |
2140 KB |
Output is correct |
42 |
Correct |
9 ms |
1484 KB |
Output is correct |
43 |
Correct |
10 ms |
1484 KB |
Output is correct |
44 |
Correct |
14 ms |
1776 KB |
Output is correct |
45 |
Correct |
15 ms |
1740 KB |
Output is correct |
46 |
Correct |
16 ms |
1812 KB |
Output is correct |
47 |
Correct |
21 ms |
2328 KB |
Output is correct |
48 |
Correct |
60 ms |
4036 KB |
Output is correct |
49 |
Correct |
129 ms |
6508 KB |
Output is correct |
50 |
Correct |
211 ms |
8984 KB |
Output is correct |
51 |
Correct |
308 ms |
11576 KB |
Output is correct |
52 |
Correct |
182 ms |
7984 KB |
Output is correct |
53 |
Correct |
179 ms |
8088 KB |
Output is correct |
54 |
Correct |
368 ms |
13412 KB |
Output is correct |
55 |
Correct |
357 ms |
13488 KB |
Output is correct |
56 |
Correct |
594 ms |
36344 KB |
Output is correct |
57 |
Execution timed out |
1087 ms |
56132 KB |
Time limit exceeded |
58 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
1 ms |
716 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
716 KB |
Output is correct |
5 |
Correct |
1 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
1 ms |
824 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
1 ms |
844 KB |
Output is correct |
13 |
Correct |
1 ms |
716 KB |
Output is correct |
14 |
Correct |
1 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
16 |
Correct |
2 ms |
844 KB |
Output is correct |
17 |
Correct |
4 ms |
1112 KB |
Output is correct |
18 |
Correct |
2 ms |
796 KB |
Output is correct |
19 |
Correct |
2 ms |
796 KB |
Output is correct |
20 |
Correct |
1 ms |
716 KB |
Output is correct |
21 |
Correct |
2 ms |
800 KB |
Output is correct |
22 |
Correct |
2 ms |
716 KB |
Output is correct |
23 |
Correct |
1 ms |
800 KB |
Output is correct |
24 |
Correct |
2 ms |
844 KB |
Output is correct |
25 |
Correct |
3 ms |
844 KB |
Output is correct |
26 |
Correct |
6 ms |
1228 KB |
Output is correct |
27 |
Correct |
14 ms |
1440 KB |
Output is correct |
28 |
Correct |
20 ms |
2136 KB |
Output is correct |
29 |
Correct |
10 ms |
1528 KB |
Output is correct |
30 |
Correct |
10 ms |
1484 KB |
Output is correct |
31 |
Correct |
21 ms |
1728 KB |
Output is correct |
32 |
Correct |
12 ms |
1664 KB |
Output is correct |
33 |
Correct |
16 ms |
1888 KB |
Output is correct |
34 |
Correct |
23 ms |
2352 KB |
Output is correct |
35 |
Correct |
61 ms |
4036 KB |
Output is correct |
36 |
Correct |
125 ms |
6616 KB |
Output is correct |
37 |
Correct |
201 ms |
8988 KB |
Output is correct |
38 |
Correct |
305 ms |
11616 KB |
Output is correct |
39 |
Correct |
212 ms |
8052 KB |
Output is correct |
40 |
Correct |
190 ms |
7968 KB |
Output is correct |
41 |
Correct |
359 ms |
13416 KB |
Output is correct |
42 |
Correct |
369 ms |
13460 KB |
Output is correct |
43 |
Correct |
594 ms |
36188 KB |
Output is correct |
44 |
Execution timed out |
1079 ms |
54852 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |