답안 #107965

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107965 2019-04-26T10:54:12 Z dfistric Bali Sculptures (APIO15_sculpture) C++14
16 / 100
1000 ms 1024 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) {
        dp2[i][1] = 0;
        if (val(pref[i]) < (1LL << x)) dp2[i][1] = 1;
        FOR(j, 2, MAXN) {
            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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 11 ms 472 KB Output is correct
6 Correct 21 ms 512 KB Output is correct
7 Correct 27 ms 588 KB Output is correct
8 Correct 40 ms 512 KB Output is correct
9 Correct 32 ms 632 KB Output is correct
10 Correct 39 ms 512 KB Output is correct
11 Correct 34 ms 584 KB Output is correct
12 Correct 33 ms 548 KB Output is correct
13 Correct 34 ms 632 KB Output is correct
14 Correct 4 ms 432 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 10 ms 512 KB Output is correct
19 Correct 21 ms 512 KB Output is correct
20 Correct 27 ms 564 KB Output is correct
21 Correct 43 ms 512 KB Output is correct
22 Correct 36 ms 512 KB Output is correct
23 Correct 35 ms 512 KB Output is correct
24 Correct 39 ms 512 KB Output is correct
25 Correct 43 ms 604 KB Output is correct
26 Correct 33 ms 632 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 11 ms 512 KB Output is correct
29 Correct 14 ms 384 KB Output is correct
30 Incorrect 35 ms 512 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 9 ms 512 KB Output is correct
6 Correct 19 ms 512 KB Output is correct
7 Correct 26 ms 512 KB Output is correct
8 Correct 39 ms 512 KB Output is correct
9 Correct 37 ms 512 KB Output is correct
10 Correct 43 ms 584 KB Output is correct
11 Correct 33 ms 512 KB Output is correct
12 Correct 51 ms 556 KB Output is correct
13 Correct 70 ms 512 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 13 ms 512 KB Output is correct
19 Correct 22 ms 512 KB Output is correct
20 Correct 30 ms 512 KB Output is correct
21 Correct 41 ms 512 KB Output is correct
22 Correct 42 ms 512 KB Output is correct
23 Correct 34 ms 512 KB Output is correct
24 Correct 36 ms 564 KB Output is correct
25 Correct 33 ms 584 KB Output is correct
26 Correct 32 ms 512 KB Output is correct
27 Correct 78 ms 512 KB Output is correct
28 Correct 64 ms 512 KB Output is correct
29 Correct 154 ms 724 KB Output is correct
30 Correct 222 ms 640 KB Output is correct
31 Correct 318 ms 768 KB Output is correct
32 Correct 315 ms 888 KB Output is correct
33 Correct 304 ms 888 KB Output is correct
34 Correct 315 ms 888 KB Output is correct
35 Correct 292 ms 888 KB Output is correct
36 Correct 281 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 10 ms 484 KB Output is correct
6 Correct 28 ms 512 KB Output is correct
7 Correct 30 ms 512 KB Output is correct
8 Correct 41 ms 512 KB Output is correct
9 Correct 51 ms 512 KB Output is correct
10 Correct 43 ms 512 KB Output is correct
11 Correct 45 ms 512 KB Output is correct
12 Correct 32 ms 512 KB Output is correct
13 Correct 33 ms 512 KB Output is correct
14 Correct 48 ms 512 KB Output is correct
15 Correct 53 ms 512 KB Output is correct
16 Correct 131 ms 640 KB Output is correct
17 Correct 174 ms 640 KB Output is correct
18 Correct 240 ms 768 KB Output is correct
19 Correct 284 ms 768 KB Output is correct
20 Correct 320 ms 888 KB Output is correct
21 Correct 334 ms 764 KB Output is correct
22 Correct 271 ms 888 KB Output is correct
23 Correct 275 ms 784 KB Output is correct
24 Correct 320 ms 888 KB Output is correct
25 Correct 540 ms 1024 KB Output is correct
26 Correct 796 ms 1024 KB Output is correct
27 Execution timed out 1041 ms 1024 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 10 ms 384 KB Output is correct
6 Correct 28 ms 604 KB Output is correct
7 Correct 25 ms 512 KB Output is correct
8 Correct 57 ms 512 KB Output is correct
9 Correct 40 ms 552 KB Output is correct
10 Correct 37 ms 512 KB Output is correct
11 Correct 43 ms 512 KB Output is correct
12 Correct 43 ms 512 KB Output is correct
13 Correct 38 ms 512 KB Output is correct
14 Correct 6 ms 356 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 10 ms 384 KB Output is correct
19 Correct 25 ms 512 KB Output is correct
20 Correct 29 ms 528 KB Output is correct
21 Correct 40 ms 512 KB Output is correct
22 Correct 36 ms 512 KB Output is correct
23 Correct 39 ms 512 KB Output is correct
24 Correct 38 ms 544 KB Output is correct
25 Correct 38 ms 632 KB Output is correct
26 Correct 41 ms 512 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 9 ms 512 KB Output is correct
29 Correct 15 ms 512 KB Output is correct
30 Incorrect 28 ms 512 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 22 ms 504 KB Output is correct
7 Correct 29 ms 536 KB Output is correct
8 Correct 40 ms 512 KB Output is correct
9 Correct 38 ms 544 KB Output is correct
10 Correct 40 ms 512 KB Output is correct
11 Correct 31 ms 512 KB Output is correct
12 Correct 37 ms 512 KB Output is correct
13 Correct 50 ms 512 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 11 ms 384 KB Output is correct
16 Correct 15 ms 384 KB Output is correct
17 Incorrect 34 ms 512 KB Output isn't correct
18 Halted 0 ms 0 KB -