Submission #107970

# Submission time Handle Problem Language Result Execution time Memory
107970 2019-04-26T10:56:13 Z dfistric Bali Sculptures (APIO15_sculpture) C++14
37 / 100
82 ms 888 KB
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define ll long long

using namespace std;

const int MAXN = 2010;
ll arr[MAXN], pref[MAXN];
int n, a, b;
int dp[MAXN], out = 0;
int dp2[MAXN][MAXN];

ll val(ll sum) {
    return ((((1LL << 60) - 1) - out) & sum);
}

int solve(int x) {
    REP(i, n) {
        dp[i] = 1e9;
        if (val(pref[i]) < (1LL << x)) dp[i] = 1;
        REP(j, i) {
            if (val(pref[i] - pref[j]) < (1LL << x)) dp[i] = min(dp[i], dp[j] + 1);
        }
    }
    return dp[n - 1];
}

void solve2(int x) {
    REP(i, n + 1) {
        dp2[i][1] = 0;
        if (val(pref[i]) < (1LL << x)) dp2[i][1] = 1;
        FOR(j, 2, n + 1) {
            dp2[i][j] = 0;
            REP(k, i) {
                if (val(pref[i] - pref[k]) < (1LL << x)) dp2[i][j] = max(dp2[i][j], dp2[k][j - 1]);
            }
        }
    }
    return;
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> a >> b;
    REP(i, n) cin >> arr[i];
    REP(i, n) {
        pref[i] = arr[i];
        if (i) pref[i] += pref[i - 1];
    }

    /*if (a == 1) {
        FORd(i, 50, 0) {
            if (solve(i) > b) out |= (1LL << i); 
        }
        cout << out << "\n";
    } else {*/
        FORd(i, 50, 0) {
            solve2(i);
            int fl = 0;
            FOR(j, a, b + 1) fl = max(fl, dp2[n - 1][j]);

            if (!fl) out |= (1LL << i);
        }
        cout << out << "\n";
    //}

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 484 KB Output is correct
13 Correct 3 ms 512 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Incorrect 3 ms 512 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 4 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 11 ms 512 KB Output is correct
30 Correct 5 ms 512 KB Output is correct
31 Correct 9 ms 640 KB Output is correct
32 Correct 11 ms 640 KB Output is correct
33 Correct 11 ms 640 KB Output is correct
34 Correct 11 ms 640 KB Output is correct
35 Correct 9 ms 512 KB Output is correct
36 Correct 8 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 3 ms 512 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 7 ms 512 KB Output is correct
18 Correct 9 ms 640 KB Output is correct
19 Correct 8 ms 512 KB Output is correct
20 Correct 10 ms 640 KB Output is correct
21 Correct 9 ms 512 KB Output is correct
22 Correct 9 ms 640 KB Output is correct
23 Correct 10 ms 640 KB Output is correct
24 Correct 8 ms 556 KB Output is correct
25 Correct 16 ms 640 KB Output is correct
26 Correct 27 ms 760 KB Output is correct
27 Correct 45 ms 824 KB Output is correct
28 Correct 54 ms 768 KB Output is correct
29 Correct 65 ms 888 KB Output is correct
30 Correct 82 ms 768 KB Output is correct
31 Correct 74 ms 820 KB Output is correct
32 Correct 61 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 556 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 356 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 412 KB Output is correct
30 Incorrect 2 ms 384 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 356 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Incorrect 3 ms 384 KB Output isn't correct
18 Halted 0 ms 0 KB -