Submission #112050

# Submission time Handle Problem Language Result Execution time Memory
112050 2019-05-17T07:35:15 Z Eug1ena Bali Sculptures (APIO15_sculpture) C++14
100 / 100
192 ms 632 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

int N, A, B;
vector<lint> sum{0};

lint notbit = 0;

lint dp[105][105];

bool minimum(int now, int cnt){
    if(now == N){
        return (A <= cnt && cnt <= B);
    }else if(dp[now][cnt] != -1){
        return dp[now][cnt];
    }
    int ans = false;
    for(int i = now + 1; i <= N; i++){
        if(((sum[i] - sum[now]) & notbit) == 0){
            ans |= minimum(i, cnt + 1);
        }
    }
    return dp[now][cnt] = ans;
}

int dp2[2020];

int minimum2(int now){
    if(now == N){
        return 0;
    }else if(dp2[now] != -1){
        return dp2[now];
    }
    int ans = 1e9;
    for(int i = now + 1; i <= N; i++){
        if(((sum[i] - sum[now]) & notbit) == 0){
            ans = min(ans, minimum2(i));
        }
    }
    return dp2[now] = ans + 1;
}

int main(){
    cin >> N >> A >> B;
    for(int i = 0; i < N; i++){
        lint Y;
        cin >> Y;
        lint item = sum.back() + Y;
        sum.push_back(item);
    }
    for(int i = 59; i >= 0; i--){
        notbit += (1l << i);
        if(N <= 100){
            memset(dp, -1, sizeof(dp));
            if(!minimum(0, 0)){
                notbit -= (1l << i);
            }
        }else{
            memset(dp2, -1, sizeof(dp2));
            if(minimum2(0) > B){
                notbit -= (1l << i);
            }
        }
    }
    cout << (1l << 60) - 1 - notbit << endl;
}

Compilation message

sculpture.cpp: In function 'bool minimum(int, int)':
sculpture.cpp:24:25: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     return dp[now][cnt] = ans;
            ~~~~~~~~~~~~~^~~~~
# 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 1 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 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 412 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 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 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 2 ms 384 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 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 412 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 3 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 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 1 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 8 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 8 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 8 ms 384 KB Output is correct
36 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 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 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 8 ms 384 KB Output is correct
19 Correct 8 ms 384 KB Output is correct
20 Correct 8 ms 384 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 8 ms 384 KB Output is correct
24 Correct 8 ms 384 KB Output is correct
25 Correct 14 ms 384 KB Output is correct
26 Correct 22 ms 480 KB Output is correct
27 Correct 35 ms 384 KB Output is correct
28 Correct 52 ms 384 KB Output is correct
29 Correct 44 ms 504 KB Output is correct
30 Correct 46 ms 512 KB Output is correct
31 Correct 43 ms 384 KB Output is correct
32 Correct 53 ms 448 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 3 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 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 432 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 384 KB Output is correct
24 Correct 2 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 3 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 7 ms 384 KB Output is correct
41 Correct 8 ms 588 KB Output is correct
42 Correct 9 ms 384 KB Output is correct
43 Correct 9 ms 384 KB Output is correct
44 Correct 9 ms 512 KB Output is correct
45 Correct 8 ms 384 KB Output is correct
46 Correct 8 ms 384 KB Output is correct
47 Correct 9 ms 384 KB Output is correct
48 Correct 18 ms 384 KB Output is correct
49 Correct 23 ms 384 KB Output is correct
50 Correct 34 ms 384 KB Output is correct
51 Correct 45 ms 452 KB Output is correct
52 Correct 43 ms 504 KB Output is correct
53 Correct 45 ms 452 KB Output is correct
54 Correct 44 ms 384 KB Output is correct
55 Correct 43 ms 488 KB Output is correct
56 Correct 5 ms 384 KB Output is correct
57 Correct 13 ms 384 KB Output is correct
58 Correct 19 ms 384 KB Output is correct
59 Correct 24 ms 384 KB Output is correct
60 Correct 36 ms 504 KB Output is correct
61 Correct 30 ms 488 KB Output is correct
62 Correct 27 ms 384 KB Output is correct
63 Correct 32 ms 456 KB Output is correct
64 Correct 35 ms 504 KB Output is correct
65 Correct 6 ms 384 KB Output is correct
66 Correct 9 ms 384 KB Output is correct
67 Correct 13 ms 496 KB Output is correct
68 Correct 19 ms 384 KB Output is correct
69 Correct 25 ms 384 KB Output is correct
70 Correct 29 ms 384 KB Output is correct
71 Correct 32 ms 384 KB Output is correct
72 Correct 28 ms 384 KB Output is correct
73 Correct 27 ms 384 KB Output is correct
74 Correct 26 ms 384 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 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 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 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 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 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 9 ms 384 KB Output is correct
29 Correct 8 ms 384 KB Output is correct
30 Correct 8 ms 384 KB Output is correct
31 Correct 8 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 8 ms 384 KB Output is correct
34 Correct 9 ms 384 KB Output is correct
35 Correct 14 ms 384 KB Output is correct
36 Correct 27 ms 384 KB Output is correct
37 Correct 34 ms 384 KB Output is correct
38 Correct 53 ms 452 KB Output is correct
39 Correct 44 ms 384 KB Output is correct
40 Correct 50 ms 384 KB Output is correct
41 Correct 45 ms 384 KB Output is correct
42 Correct 44 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 16 ms 384 KB Output is correct
45 Correct 18 ms 384 KB Output is correct
46 Correct 26 ms 384 KB Output is correct
47 Correct 23 ms 384 KB Output is correct
48 Correct 24 ms 384 KB Output is correct
49 Correct 32 ms 384 KB Output is correct
50 Correct 26 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 17 ms 384 KB Output is correct
53 Correct 22 ms 384 KB Output is correct
54 Correct 53 ms 472 KB Output is correct
55 Correct 43 ms 384 KB Output is correct
56 Correct 135 ms 512 KB Output is correct
57 Correct 130 ms 536 KB Output is correct
58 Correct 140 ms 536 KB Output is correct
59 Correct 159 ms 512 KB Output is correct
60 Correct 139 ms 528 KB Output is correct
61 Correct 3 ms 384 KB Output is correct
62 Correct 21 ms 384 KB Output is correct
63 Correct 53 ms 384 KB Output is correct
64 Correct 36 ms 468 KB Output is correct
65 Correct 70 ms 384 KB Output is correct
66 Correct 104 ms 512 KB Output is correct
67 Correct 131 ms 512 KB Output is correct
68 Correct 192 ms 632 KB Output is correct
69 Correct 141 ms 512 KB Output is correct