Submission #582473

# Submission time Handle Problem Language Result Execution time Memory
582473 2022-06-23T21:47:47 Z gg123_pe Bali Sculptures (APIO15_sculpture) C++14
25 / 100
38 ms 896 KB
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll; 
typedef pair<ll,int> ii; 

#define f(i,a,b) for(int i = a; i < b; i++)
#define fa(i,a,b) for(int i = a; i >= b; i--)

const int N = 2005; 
const ll inf = 1e18 + 10;


int n, a, b, x[55];
bool dp[55][21][505]; 

bool on(int x, int pos){
    return (x&(1LL<<pos)); 
}
int main(){
    cin >> n >> a >> b; 

    f(i,1,n+1) cin >> x[i]; 

    if(n <= 20){    
        ll ans = inf; 

        f(i,1,(1<<n)){
            int xi = __builtin_popcount(i); 
            if(xi < a or b < xi or i%2 == 0) continue; 

            ll res = 0, id = 0; 

            while(id < n){
                ll c = x[id+1]; 
                id++; 
                
                while(id < n and !on(i,id)) {
                    c += x[id+1]; 
                    id++; 
                }
                res |= c; 
                
            }
        
            ans = min(ans, res); 
        }
        cout << ans << "\n"; 
        return 0;
    }
    dp[0][0][0] = 1; 

    f(i,1,n+1){ 
        int s = 0; 
        fa(j,i,1){
            s += x[j]; 

            fa(g,min(20,i),1){
                f(k,0,501) {
                    if(dp[j-1][g-1][k])
                        dp[i][g][(k|s)] = 1; 
                }
            }
    
        }
    }
    int ans = 10000; 

    f(i,a,b+1){
        f(j,0,505) if(dp[n][i][j]) ans = min(ans, j); 
    }
    cout << ans << "\n"; 
    return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 3 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 3 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 37 ms 304 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 6 ms 308 KB Output is correct
22 Correct 6 ms 212 KB Output is correct
23 Correct 6 ms 308 KB Output is correct
24 Correct 3 ms 212 KB Output is correct
25 Correct 6 ms 212 KB Output is correct
26 Correct 32 ms 308 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 3 ms 212 KB Output is correct
31 Correct 6 ms 312 KB Output is correct
32 Correct 5 ms 212 KB Output is correct
33 Correct 32 ms 212 KB Output is correct
34 Correct 35 ms 212 KB Output is correct
35 Correct 5 ms 212 KB Output is correct
36 Correct 33 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 3 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 3 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 304 KB Output is correct
13 Correct 34 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 6 ms 304 KB Output is correct
22 Correct 6 ms 308 KB Output is correct
23 Correct 6 ms 312 KB Output is correct
24 Correct 3 ms 212 KB Output is correct
25 Correct 6 ms 212 KB Output is correct
26 Correct 36 ms 212 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 7 ms 596 KB Output is correct
30 Correct 8 ms 596 KB Output is correct
31 Correct 12 ms 724 KB Output is correct
32 Correct 12 ms 724 KB Output is correct
33 Correct 11 ms 764 KB Output is correct
34 Correct 10 ms 724 KB Output is correct
35 Correct 11 ms 772 KB Output is correct
36 Correct 12 ms 788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 3 ms 212 KB Output is correct
9 Correct 4 ms 308 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Correct 5 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 38 ms 288 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 6 ms 596 KB Output is correct
17 Correct 8 ms 692 KB Output is correct
18 Correct 11 ms 724 KB Output is correct
19 Correct 11 ms 764 KB Output is correct
20 Correct 11 ms 672 KB Output is correct
21 Correct 11 ms 724 KB Output is correct
22 Correct 11 ms 680 KB Output is correct
23 Correct 11 ms 724 KB Output is correct
24 Correct 13 ms 668 KB Output is correct
25 Incorrect 1 ms 212 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 300 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 34 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 6 ms 312 KB Output is correct
22 Correct 6 ms 212 KB Output is correct
23 Correct 6 ms 212 KB Output is correct
24 Correct 3 ms 308 KB Output is correct
25 Correct 7 ms 212 KB Output is correct
26 Correct 32 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
31 Correct 6 ms 308 KB Output is correct
32 Correct 4 ms 212 KB Output is correct
33 Correct 32 ms 212 KB Output is correct
34 Correct 35 ms 336 KB Output is correct
35 Correct 3 ms 212 KB Output is correct
36 Correct 33 ms 288 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 3 ms 512 KB Output is correct
39 Correct 6 ms 596 KB Output is correct
40 Correct 8 ms 676 KB Output is correct
41 Correct 11 ms 744 KB Output is correct
42 Correct 11 ms 752 KB Output is correct
43 Correct 10 ms 764 KB Output is correct
44 Correct 10 ms 724 KB Output is correct
45 Correct 11 ms 896 KB Output is correct
46 Correct 11 ms 724 KB Output is correct
47 Correct 17 ms 796 KB Output is correct
48 Incorrect 0 ms 212 KB Output isn't correct
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 3 ms 284 KB Output is correct
9 Correct 3 ms 312 KB Output is correct
10 Correct 5 ms 308 KB Output is correct
11 Correct 5 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 36 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 6 ms 308 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 31 ms 212 KB Output is correct
21 Correct 33 ms 212 KB Output is correct
22 Correct 3 ms 212 KB Output is correct
23 Correct 35 ms 212 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 5 ms 468 KB Output is correct
26 Correct 7 ms 596 KB Output is correct
27 Correct 10 ms 596 KB Output is correct
28 Correct 12 ms 776 KB Output is correct
29 Correct 12 ms 768 KB Output is correct
30 Correct 11 ms 724 KB Output is correct
31 Correct 13 ms 716 KB Output is correct
32 Correct 11 ms 756 KB Output is correct
33 Correct 11 ms 680 KB Output is correct
34 Correct 13 ms 688 KB Output is correct
35 Incorrect 0 ms 212 KB Output isn't correct
36 Halted 0 ms 0 KB -