Submission #880414

# Submission time Handle Problem Language Result Execution time Memory
880414 2023-11-29T11:36:42 Z JakobZorz Bali Sculptures (APIO15_sculpture) C++14
25 / 100
17 ms 604 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second

const int NUM_BITS=41;
int arr[2000];
int n,a,b;

bool is_possible(ll mask){
    vector<vector<bool>>dp(n+1,vector<bool>(n,false)); // dp[i][j] if we take the subarray arr[0..i] can we partition it into j groups so that all sums | mask == mask
    dp[0][0]=true;
    for(int i=0;i<=n;i++){
        ll sum=0;
        for(int j=i-1;j>=0;j--){
            sum+=arr[j];
            if((sum|mask)==mask){
                for(int k=0;k<i;k++){
                    if(dp[j][k])
                        dp[i][k+1]=true;
                }
            }
        }
    }
    for(int i=a;i<=b;i++){
        if(dp[n][i])
            return true;
    }
    return false;
}

void solve(){
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    ll mask=(1LL<<NUM_BITS)-1;
    
    for(int i=NUM_BITS-1;i>=0;i--){
        mask^=1LL<<i;
        if(!is_possible(mask))
            mask^=1LL<<i;
    }
    cout<<mask<<"\n";
}

int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("bank.in","r",stdin);freopen("bank.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}

/*
 
6 1 3
8 1 2 1 5 4
 
 */
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 372 KB Output is correct
10 Correct 0 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 344 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 348 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 1 ms 348 KB Output is correct
25 Correct 0 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 0 ms 348 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 460 KB Output is correct
33 Correct 0 ms 464 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 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 1 ms 348 KB Output is correct
11 Correct 1 ms 352 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 460 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
17 Correct 0 ms 352 KB Output is correct
18 Correct 0 ms 352 KB Output is correct
19 Correct 0 ms 352 KB Output is correct
20 Correct 1 ms 352 KB Output is correct
21 Correct 0 ms 352 KB Output is correct
22 Correct 0 ms 464 KB Output is correct
23 Correct 0 ms 456 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 344 KB Output is correct
31 Correct 3 ms 464 KB Output is correct
32 Correct 3 ms 348 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 3 ms 348 KB Output is correct
35 Correct 3 ms 348 KB Output is correct
36 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 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 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 4 ms 344 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 460 KB Output is correct
23 Correct 3 ms 460 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 9 ms 460 KB Output is correct
27 Correct 13 ms 348 KB Output is correct
28 Incorrect 17 ms 460 KB Output isn't correct
29 Halted 0 ms 0 KB -
# 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 348 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 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 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 604 KB Output is correct
20 Correct 0 ms 352 KB Output is correct
21 Correct 1 ms 352 KB Output is correct
22 Correct 1 ms 352 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 352 KB Output is correct
25 Correct 0 ms 352 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 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 360 KB Output is correct
33 Correct 0 ms 360 KB Output is correct
34 Correct 0 ms 464 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 2 ms 348 KB Output is correct
41 Correct 3 ms 348 KB Output is correct
42 Correct 3 ms 348 KB Output is correct
43 Correct 3 ms 348 KB Output is correct
44 Correct 3 ms 348 KB Output is correct
45 Correct 3 ms 348 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 3 ms 348 KB Output is correct
48 Correct 5 ms 348 KB Output is correct
49 Correct 9 ms 348 KB Output is correct
50 Correct 13 ms 464 KB Output is correct
51 Incorrect 17 ms 348 KB Output isn't correct
52 Halted 0 ms 0 KB -
# 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 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 1 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 0 ms 600 KB Output is correct
17 Correct 0 ms 348 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 1 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 3 ms 468 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 3 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 3 ms 348 KB Output is correct
34 Correct 3 ms 348 KB Output is correct
35 Correct 6 ms 464 KB Output is correct
36 Correct 8 ms 348 KB Output is correct
37 Correct 13 ms 344 KB Output is correct
38 Incorrect 17 ms 348 KB Output isn't correct
39 Halted 0 ms 0 KB -