Submission #506804

# Submission time Handle Problem Language Result Execution time Memory
506804 2022-01-12T07:01:01 Z Aldas25 Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 1476 KB
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;

const int MAXN = 2100;
const ll INF = (ll)1e17;

int n, a, b;
ll y[MAXN];
ll pref[MAXN];
bool dp[MAXN][MAXN];

bool check (ll mask) {
   // cout << " mask = " << mask << endl;

    FOR(i, 0, n) FOR(g, 0, n) dp[i][g] = false;

    dp[0][0] = true;

    FOR(i, 1, n) FOR(g, 1, i) {
        FOR(j, g-1, i-1) {
            if (!dp[j][g-1]) continue;
            ll sum = pref[i]-pref[j];
            if (sum & mask) continue;
            dp[i][g] = true;
            //cout << " i = " << i << " g = " << g << " is true  for j = " << j << endl;
            break;
        }
    }

    FOR(x, a, b)
        if (dp[n][x])
            return true;
    return false;
}

int main()
{
    FAST_IO;

    cin >> n >> a >> b;
    FOR(i, 1, n) cin >> y[i];
    FOR(i, 1, n) pref[i] = pref[i-1] + y[i];

    ll ans = 0;
    for (ll k = 50; k >= 0; k--) {
        ll cur = ans + (1ll<<k) - 1ll;
        ll inv = ~cur;
        if (!check(inv))
            ans += (1ll << k);
    }

    cout << ans << "\n";

    return 0;
}

/*
in:
6 1 3
8 1 2 1 5 4
ans: 11

in:
6 1 6
8 1 2 1 5 4

*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 304 KB Output is correct
29 Correct 0 ms 316 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 312 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 316 KB Output is correct
35 Correct 1 ms 324 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 332 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 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 3 ms 460 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 320 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 316 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 0 ms 320 KB Output is correct
37 Correct 0 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 316 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 3 ms 460 KB Output is correct
50 Correct 3 ms 448 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 3 ms 460 KB Output is correct
53 Correct 2 ms 440 KB Output is correct
54 Correct 2 ms 460 KB Output is correct
55 Correct 2 ms 448 KB Output is correct
56 Correct 2 ms 332 KB Output is correct
57 Correct 4 ms 444 KB Output is correct
58 Correct 4 ms 460 KB Output is correct
59 Correct 5 ms 460 KB Output is correct
60 Correct 6 ms 532 KB Output is correct
61 Correct 7 ms 448 KB Output is correct
62 Correct 6 ms 460 KB Output is correct
63 Correct 7 ms 460 KB Output is correct
64 Correct 1 ms 460 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 2 ms 444 KB Output is correct
67 Correct 3 ms 460 KB Output is correct
68 Correct 5 ms 472 KB Output is correct
69 Correct 5 ms 460 KB Output is correct
70 Correct 6 ms 472 KB Output is correct
71 Correct 8 ms 460 KB Output is correct
72 Correct 6 ms 540 KB Output is correct
73 Correct 6 ms 460 KB Output is correct
74 Correct 6 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 0 ms 300 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 320 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 320 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 1 ms 428 KB Output is correct
36 Correct 2 ms 452 KB Output is correct
37 Correct 2 ms 460 KB Output is correct
38 Correct 4 ms 460 KB Output is correct
39 Correct 2 ms 460 KB Output is correct
40 Correct 2 ms 460 KB Output is correct
41 Correct 3 ms 460 KB Output is correct
42 Correct 2 ms 460 KB Output is correct
43 Correct 2 ms 332 KB Output is correct
44 Correct 4 ms 588 KB Output is correct
45 Correct 7 ms 452 KB Output is correct
46 Correct 5 ms 452 KB Output is correct
47 Correct 6 ms 460 KB Output is correct
48 Correct 7 ms 440 KB Output is correct
49 Correct 6 ms 532 KB Output is correct
50 Correct 7 ms 536 KB Output is correct
51 Correct 7 ms 540 KB Output is correct
52 Execution timed out 1064 ms 1476 KB Time limit exceeded
53 Halted 0 ms 0 KB -