//******************/
//* I<3 C++ */
//* I WANT ANY AC */
//* I LOVE PROGRAM!*/
//*IT'S long longERESTING*/
//* I LOVE PROGRAM!*/
//* IN CONTESTS */
//* GET SCORE */
//* AC CODE */
//* LET'S */
//* GO */
//* Written by: */
//* Duc Minh */
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <string>
#include <queue>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <deque>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define file(name) freopen(name".inp", "r", stdin);\
freopen(name".out", "w", stdout);
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define all(a) a.begin(),a.end()
#define endl "\n"
#define all1(a) a+1,a+n+1
#define unordered_map map
#define Accepted 0
// #define push_back emplace_back
// #define gcd(a,b) __gcd(a,b);
// #define lcm(a,b) (a*b)/gcd(a,b);
const long long INF = (long long)1e9;
const long long MOD = (long long)1e9+7;
const long long MODD = 14062008; /// 998244353
const long long maxN = 2e5+9;
const long long LOG = 30;
///--------------------------------
void solve();
signed main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long t;
// cin >> t;
t=1;
while (t--){
solve();
}
return Accepted;
}
///--------------------[PROBLEM SOLUTION]--------------------///
int a[200009];
void solve(){
int ans=INF,n,L,R;
cin >> n >> L >> R;
for (int i=0; i<n; i++){
cin >> a[i];
}
for (int mask=0; mask<(1<<n); mask++){
int sum=0,g=0;
for (int i=0; i<n; i++){
sum+=a[i];
if ((mask>>i)&1){
g|=sum;
sum=0;
}
}
g|=sum;
int bits=__builtin_popcount(mask) + ((mask & (1 << (n - 1))) == 0);
if (L<=bits && bits<=R) ans=min(ans,g);
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
9 ms |
468 KB |
Output is correct |
8 |
Correct |
70 ms |
348 KB |
Output is correct |
9 |
Correct |
71 ms |
348 KB |
Output is correct |
10 |
Correct |
71 ms |
348 KB |
Output is correct |
11 |
Correct |
71 ms |
348 KB |
Output is correct |
12 |
Correct |
71 ms |
344 KB |
Output is correct |
13 |
Correct |
78 ms |
452 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
10 ms |
464 KB |
Output is correct |
21 |
Correct |
69 ms |
348 KB |
Output is correct |
22 |
Correct |
68 ms |
348 KB |
Output is correct |
23 |
Correct |
70 ms |
440 KB |
Output is correct |
24 |
Correct |
76 ms |
436 KB |
Output is correct |
25 |
Correct |
69 ms |
436 KB |
Output is correct |
26 |
Correct |
69 ms |
348 KB |
Output is correct |
27 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
348 KB |
Output is correct |
8 |
Correct |
71 ms |
348 KB |
Output is correct |
9 |
Correct |
72 ms |
440 KB |
Output is correct |
10 |
Correct |
76 ms |
592 KB |
Output is correct |
11 |
Correct |
71 ms |
348 KB |
Output is correct |
12 |
Correct |
71 ms |
348 KB |
Output is correct |
13 |
Correct |
73 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
9 ms |
348 KB |
Output is correct |
21 |
Correct |
69 ms |
348 KB |
Output is correct |
22 |
Correct |
70 ms |
440 KB |
Output is correct |
23 |
Correct |
68 ms |
440 KB |
Output is correct |
24 |
Correct |
74 ms |
348 KB |
Output is correct |
25 |
Correct |
70 ms |
456 KB |
Output is correct |
26 |
Correct |
69 ms |
440 KB |
Output is correct |
27 |
Correct |
145 ms |
440 KB |
Output is correct |
28 |
Execution timed out |
1077 ms |
348 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
432 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
9 ms |
348 KB |
Output is correct |
8 |
Correct |
71 ms |
440 KB |
Output is correct |
9 |
Correct |
71 ms |
348 KB |
Output is correct |
10 |
Correct |
72 ms |
348 KB |
Output is correct |
11 |
Correct |
73 ms |
440 KB |
Output is correct |
12 |
Correct |
73 ms |
436 KB |
Output is correct |
13 |
Correct |
71 ms |
436 KB |
Output is correct |
14 |
Correct |
145 ms |
692 KB |
Output is correct |
15 |
Execution timed out |
1014 ms |
344 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
9 ms |
464 KB |
Output is correct |
8 |
Correct |
71 ms |
348 KB |
Output is correct |
9 |
Correct |
71 ms |
440 KB |
Output is correct |
10 |
Correct |
71 ms |
348 KB |
Output is correct |
11 |
Correct |
75 ms |
444 KB |
Output is correct |
12 |
Correct |
71 ms |
348 KB |
Output is correct |
13 |
Correct |
71 ms |
440 KB |
Output is correct |
14 |
Correct |
0 ms |
544 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
9 ms |
344 KB |
Output is correct |
21 |
Correct |
68 ms |
348 KB |
Output is correct |
22 |
Correct |
72 ms |
440 KB |
Output is correct |
23 |
Correct |
75 ms |
344 KB |
Output is correct |
24 |
Correct |
72 ms |
344 KB |
Output is correct |
25 |
Correct |
68 ms |
348 KB |
Output is correct |
26 |
Correct |
68 ms |
440 KB |
Output is correct |
27 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
460 KB |
Output is correct |
8 |
Correct |
71 ms |
440 KB |
Output is correct |
9 |
Correct |
73 ms |
348 KB |
Output is correct |
10 |
Correct |
72 ms |
348 KB |
Output is correct |
11 |
Correct |
71 ms |
344 KB |
Output is correct |
12 |
Correct |
71 ms |
348 KB |
Output is correct |
13 |
Correct |
71 ms |
440 KB |
Output is correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |