Submission #922831

# Submission time Handle Problem Language Result Execution time Memory
922831 2024-02-06T07:34:26 Z vjudge1 Bali Sculptures (APIO15_sculpture) C++17
71 / 100
479 ms 856 KB
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;

template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */

const int N = 2e3 + 7;

int n, a[N], A, B;

ll pre[N];

ll getSum(int i, int j) {
    return pre[j] - pre[i - 1];
}

namespace sub1 {
    const int N = 107;
    const int M = 45;
    bool f[N][N];
    ll solve(int m) {
        ll res = 0;
        FORD(x, M, 0) {
            FOR(i, 0, n)
                FOR(j, 0, m + 1) f[i][j] = false;
            f[0][0] = true;
            REP(i, 0, n)
                FOR(j, 0, m)
                    if (f[i][j]) {
                        FOR(k, i + 1, n) {
                            ll sum = getSum(i + 1, k);
                            if (((res | sum) <= res + MASK(x) - 1)) {
                                f[k][j + 1] = true;
                            }
                        }
                    }
            if (f[n][m]) continue;
            res^=MASK(x);
        }
        return res;
    }
    void Process() {
        ll res = 1e18;
        FOR(x, A, B) minimize(res, solve(x));
        cout<<res;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>A>>B;
    FOR(i, 1, n) {
        cin>>a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    if (n <= 100) {
        sub1::Process();
        return 0;
    }
    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 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 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 344 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 0 ms 348 KB Output is correct
16 Correct 0 ms 464 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 348 KB Output is correct
20 Correct 0 ms 456 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 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 348 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 456 KB Output is correct
30 Correct 0 ms 348 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 0 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 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 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 1 ms 456 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 600 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 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 5 ms 344 KB Output is correct
31 Correct 8 ms 348 KB Output is correct
32 Correct 9 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 8 ms 348 KB Output is correct
35 Correct 6 ms 348 KB Output is correct
36 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 8 ms 352 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 8 ms 468 KB Output is correct
22 Correct 6 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 6 ms 468 KB Output is correct
26 Correct 25 ms 348 KB Output is correct
27 Correct 141 ms 348 KB Output is correct
28 Correct 436 ms 600 KB Output is correct
29 Correct 433 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 152 ms 456 KB Output is correct
32 Correct 288 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 348 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 420 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 472 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 344 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 348 KB Output is correct
22 Correct 0 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 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 600 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 4 ms 348 KB Output is correct
41 Correct 8 ms 348 KB Output is correct
42 Correct 8 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 7 ms 348 KB Output is correct
45 Correct 6 ms 476 KB Output is correct
46 Correct 3 ms 348 KB Output is correct
47 Correct 9 ms 464 KB Output is correct
48 Correct 5 ms 400 KB Output is correct
49 Correct 28 ms 348 KB Output is correct
50 Correct 136 ms 592 KB Output is correct
51 Correct 427 ms 856 KB Output is correct
52 Correct 431 ms 448 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 142 ms 460 KB Output is correct
55 Correct 282 ms 456 KB Output is correct
56 Correct 6 ms 348 KB Output is correct
57 Correct 13 ms 600 KB Output is correct
58 Correct 63 ms 348 KB Output is correct
59 Correct 179 ms 452 KB Output is correct
60 Correct 223 ms 344 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 231 ms 344 KB Output is correct
63 Correct 267 ms 448 KB Output is correct
64 Correct 194 ms 592 KB Output is correct
65 Correct 3 ms 348 KB Output is correct
66 Correct 3 ms 344 KB Output is correct
67 Correct 12 ms 344 KB Output is correct
68 Correct 55 ms 348 KB Output is correct
69 Correct 108 ms 344 KB Output is correct
70 Correct 139 ms 452 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 221 ms 448 KB Output is correct
73 Correct 75 ms 344 KB Output is correct
74 Correct 87 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 460 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 544 KB Output is correct
13 Correct 1 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 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 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 2 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 8 ms 348 KB Output is correct
29 Correct 10 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 9 ms 348 KB Output is correct
32 Correct 7 ms 460 KB Output is correct
33 Correct 3 ms 348 KB Output is correct
34 Correct 8 ms 472 KB Output is correct
35 Correct 4 ms 348 KB Output is correct
36 Correct 25 ms 348 KB Output is correct
37 Correct 139 ms 348 KB Output is correct
38 Correct 479 ms 596 KB Output is correct
39 Correct 423 ms 452 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 142 ms 456 KB Output is correct
42 Correct 277 ms 452 KB Output is correct
43 Correct 5 ms 348 KB Output is correct
44 Correct 16 ms 480 KB Output is correct
45 Correct 65 ms 348 KB Output is correct
46 Correct 188 ms 456 KB Output is correct
47 Correct 218 ms 452 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 282 ms 452 KB Output is correct
50 Correct 276 ms 452 KB Output is correct
51 Incorrect 0 ms 344 KB Output isn't correct
52 Halted 0 ms 0 KB -