/*
Code written by Talant I.D.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
const int mod = 1e9+7;
ll mode(ll a) {
a %= mod;
if (a < 0) a += mod;
return a;
}
ll subt(ll a, ll b) {
return mode(mode(a)-mode(b));
}
ll add(ll a, ll b) {
return mode(mode(a)+mode(b));
}
ll mult(ll a, ll b) {
return mode(mode(a)*mode(b));
}
ll binpow(ll a, ll b) {
ll res = 1;
while (b) {
if (b&1) res = mult(res, a);
a = mult(a, a);
b >>= 1;
}
return res;
}
int main() {
do_not_disturb
int n, a, b;
cin >> n >> a >> b;
vector <ll> v(n), pref(n);
for (int i = 0; i < n; i++) cin >> v[i];
for (int i = 0; i < n; i++) {
pref[i] = (!i ? v[i] : pref[i-1]+v[i]);
}
if (n <= 20) {
ll ans = 9e18;
for (int mask = 0; mask < (1<<n); mask++) {
ll prev = 0, j = 0, cnt = 0, sum = 0;
while (j < n) {
while (j < n && !(mask&(1<<j))) {
j++;
}
if (prev < j) {
cnt++;
sum |= pref[j-1]-(prev == 0 ? 0 : pref[prev-1]);
}
prev = j;
j++;
}
if (prev == n-1) {
sum |= v[n-1];
cnt++;
}
if (a <= cnt && cnt <= b) {
ans = min(ans, sum);
}
}
cout << ans;
}
else if (n <= 50 && a >= 1) {
}
else if (n <= 100 && a == 1) {
}
else if (n <= 100) {
}
else {
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
10 ms |
316 KB |
Output is correct |
8 |
Correct |
75 ms |
292 KB |
Output is correct |
9 |
Correct |
76 ms |
204 KB |
Output is correct |
10 |
Correct |
79 ms |
288 KB |
Output is correct |
11 |
Correct |
77 ms |
204 KB |
Output is correct |
12 |
Correct |
75 ms |
204 KB |
Output is correct |
13 |
Correct |
76 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
3 ms |
204 KB |
Output is correct |
20 |
Correct |
9 ms |
312 KB |
Output is correct |
21 |
Correct |
75 ms |
204 KB |
Output is correct |
22 |
Correct |
98 ms |
292 KB |
Output is correct |
23 |
Correct |
105 ms |
204 KB |
Output is correct |
24 |
Correct |
76 ms |
204 KB |
Output is correct |
25 |
Correct |
100 ms |
204 KB |
Output is correct |
26 |
Correct |
86 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
37 ms |
296 KB |
Output is correct |
31 |
Correct |
78 ms |
292 KB |
Output is correct |
32 |
Correct |
87 ms |
292 KB |
Output is correct |
33 |
Correct |
76 ms |
304 KB |
Output is correct |
34 |
Correct |
90 ms |
300 KB |
Output is correct |
35 |
Correct |
75 ms |
204 KB |
Output is correct |
36 |
Correct |
76 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
10 ms |
308 KB |
Output is correct |
8 |
Correct |
89 ms |
204 KB |
Output is correct |
9 |
Correct |
81 ms |
296 KB |
Output is correct |
10 |
Correct |
82 ms |
288 KB |
Output is correct |
11 |
Correct |
87 ms |
296 KB |
Output is correct |
12 |
Correct |
79 ms |
288 KB |
Output is correct |
13 |
Correct |
77 ms |
292 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
3 ms |
312 KB |
Output is correct |
20 |
Correct |
11 ms |
204 KB |
Output is correct |
21 |
Correct |
75 ms |
292 KB |
Output is correct |
22 |
Correct |
85 ms |
204 KB |
Output is correct |
23 |
Correct |
80 ms |
292 KB |
Output is correct |
24 |
Correct |
75 ms |
204 KB |
Output is correct |
25 |
Correct |
76 ms |
204 KB |
Output is correct |
26 |
Correct |
80 ms |
204 KB |
Output is correct |
27 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
10 ms |
204 KB |
Output is correct |
8 |
Correct |
76 ms |
300 KB |
Output is correct |
9 |
Correct |
79 ms |
304 KB |
Output is correct |
10 |
Correct |
88 ms |
288 KB |
Output is correct |
11 |
Correct |
79 ms |
204 KB |
Output is correct |
12 |
Correct |
89 ms |
292 KB |
Output is correct |
13 |
Correct |
77 ms |
204 KB |
Output is correct |
14 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
9 ms |
204 KB |
Output is correct |
8 |
Correct |
76 ms |
288 KB |
Output is correct |
9 |
Correct |
75 ms |
204 KB |
Output is correct |
10 |
Correct |
76 ms |
292 KB |
Output is correct |
11 |
Correct |
77 ms |
300 KB |
Output is correct |
12 |
Correct |
76 ms |
300 KB |
Output is correct |
13 |
Correct |
76 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
3 ms |
204 KB |
Output is correct |
20 |
Correct |
10 ms |
332 KB |
Output is correct |
21 |
Correct |
76 ms |
204 KB |
Output is correct |
22 |
Correct |
77 ms |
296 KB |
Output is correct |
23 |
Correct |
75 ms |
204 KB |
Output is correct |
24 |
Correct |
77 ms |
204 KB |
Output is correct |
25 |
Correct |
78 ms |
204 KB |
Output is correct |
26 |
Correct |
75 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
37 ms |
204 KB |
Output is correct |
31 |
Correct |
75 ms |
292 KB |
Output is correct |
32 |
Correct |
75 ms |
204 KB |
Output is correct |
33 |
Correct |
76 ms |
204 KB |
Output is correct |
34 |
Correct |
76 ms |
204 KB |
Output is correct |
35 |
Correct |
75 ms |
304 KB |
Output is correct |
36 |
Correct |
76 ms |
296 KB |
Output is correct |
37 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
9 ms |
204 KB |
Output is correct |
8 |
Correct |
75 ms |
204 KB |
Output is correct |
9 |
Correct |
78 ms |
204 KB |
Output is correct |
10 |
Correct |
76 ms |
204 KB |
Output is correct |
11 |
Correct |
88 ms |
204 KB |
Output is correct |
12 |
Correct |
92 ms |
288 KB |
Output is correct |
13 |
Correct |
75 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
38 ms |
204 KB |
Output is correct |
18 |
Correct |
76 ms |
312 KB |
Output is correct |
19 |
Correct |
78 ms |
204 KB |
Output is correct |
20 |
Correct |
77 ms |
204 KB |
Output is correct |
21 |
Correct |
75 ms |
204 KB |
Output is correct |
22 |
Correct |
75 ms |
204 KB |
Output is correct |
23 |
Correct |
76 ms |
204 KB |
Output is correct |
24 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |