Submission #1008434

# Submission time Handle Problem Language Result Execution time Memory
1008434 2024-06-26T12:26:58 Z Cookie Bali Sculptures (APIO15_sculpture) C++14
71 / 100
34 ms 604 KB
#include<bits/stdc++.h>
#include<fstream>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
const ld PI = 3.14159265359, prec = 1e-9;;
//using u128 = __uint128_t;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
const ll mod = 1e9 + 7, pr = 31;
const int mxn = 2e5 + 5, mxd = 250 * 250, sq = 100, mxv = 5e4 + 1, mxq = 2e6 + 5, T = 1000;
//const int base = (1 <<18);
const ll inf = 2e9 + 5, neg = -69420, inf2 = 1e14;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, a, b;
bool dp[205][205];
ll pref[205], x[205];
ll ans = 0;
bool check(ll v){
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int took = 1; took <= n; took++){
            for(int j = i - 1; j >= 0; j--){
                if(((pref[i] - pref[j]) | v) == v){
                    dp[i][took] |= dp[j][took - 1];
                }
            }
        }
    }
    for(int i = a; i <= b; i++){
        if(dp[n][i])return(1);
    }
    return(0);
}
void solve(){
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        cin >> x[i]; pref[i] = pref[i - 1] + x[i];
    }
    for(int i = 40; i >= 0; i--){
        if(!check(ans + (1LL << i) - 1)){
            ans += (1LL << i);
        }
    }
    cout << ans;
}


 
 
 
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("TREEGCD.inp", "r", stdin);
    //freopen("TREEGCD.out", "w", stdout);
    int tt; tt = 1;
    while(tt--){
        solve();
 
    }
    return(0);
}
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 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 1 ms 464 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 396 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 464 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 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 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 3 ms 348 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Correct 5 ms 348 KB Output is correct
34 Correct 4 ms 348 KB Output is correct
35 Correct 4 ms 344 KB Output is correct
36 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 4 ms 504 KB Output is correct
21 Correct 4 ms 348 KB Output is correct
22 Correct 4 ms 508 KB Output is correct
23 Correct 4 ms 348 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 14 ms 348 KB Output is correct
27 Correct 23 ms 348 KB Output is correct
28 Correct 31 ms 348 KB Output is correct
29 Correct 32 ms 604 KB Output is correct
30 Correct 34 ms 348 KB Output is correct
31 Correct 31 ms 344 KB Output is correct
32 Correct 31 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 360 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 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 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 460 KB Output is correct
24 Correct 0 ms 352 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 456 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 464 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 2 ms 600 KB Output is correct
40 Correct 3 ms 348 KB Output is correct
41 Correct 4 ms 348 KB Output is correct
42 Correct 4 ms 604 KB Output is correct
43 Correct 4 ms 352 KB Output is correct
44 Correct 4 ms 348 KB Output is correct
45 Correct 4 ms 504 KB Output is correct
46 Correct 4 ms 348 KB Output is correct
47 Correct 4 ms 372 KB Output is correct
48 Correct 8 ms 348 KB Output is correct
49 Correct 14 ms 500 KB Output is correct
50 Correct 23 ms 348 KB Output is correct
51 Correct 31 ms 504 KB Output is correct
52 Correct 26 ms 348 KB Output is correct
53 Correct 28 ms 344 KB Output is correct
54 Correct 31 ms 344 KB Output is correct
55 Correct 31 ms 344 KB Output is correct
56 Correct 3 ms 348 KB Output is correct
57 Correct 9 ms 504 KB Output is correct
58 Correct 12 ms 500 KB Output is correct
59 Correct 19 ms 496 KB Output is correct
60 Correct 18 ms 508 KB Output is correct
61 Correct 17 ms 348 KB Output is correct
62 Correct 18 ms 508 KB Output is correct
63 Correct 20 ms 500 KB Output is correct
64 Correct 23 ms 344 KB Output is correct
65 Correct 2 ms 344 KB Output is correct
66 Correct 5 ms 500 KB Output is correct
67 Correct 11 ms 348 KB Output is correct
68 Correct 13 ms 348 KB Output is correct
69 Correct 17 ms 348 KB Output is correct
70 Correct 18 ms 500 KB Output is correct
71 Correct 17 ms 348 KB Output is correct
72 Correct 20 ms 500 KB Output is correct
73 Correct 19 ms 504 KB Output is correct
74 Correct 20 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 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 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 464 KB Output is correct
22 Correct 1 ms 356 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 4 ms 508 KB Output is correct
31 Correct 4 ms 344 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 4 ms 348 KB Output is correct
35 Correct 8 ms 500 KB Output is correct
36 Correct 14 ms 348 KB Output is correct
37 Correct 23 ms 348 KB Output is correct
38 Correct 29 ms 348 KB Output is correct
39 Correct 30 ms 348 KB Output is correct
40 Correct 31 ms 344 KB Output is correct
41 Correct 28 ms 348 KB Output is correct
42 Correct 28 ms 344 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 8 ms 348 KB Output is correct
45 Correct 14 ms 344 KB Output is correct
46 Correct 18 ms 348 KB Output is correct
47 Correct 18 ms 348 KB Output is correct
48 Correct 18 ms 348 KB Output is correct
49 Correct 20 ms 348 KB Output is correct
50 Correct 18 ms 348 KB Output is correct
51 Correct 19 ms 600 KB Output is correct
52 Runtime error 34 ms 596 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -