Submission #41693

# Submission time Handle Problem Language Result Execution time Memory
41693 2018-02-20T18:44:56 Z Hassoony Bali Sculptures (APIO15_sculpture) C++14
50 / 100
145 ms 1140 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
const ll inf=(1ll<<61);
const int MX=2009;
ll n,A,B;
ll a[MX],dp[MX],ans,sum1,dp1[109][109];
ll DP(ll x){
    if(x==n)return 0;
    ll &ret=dp[x];if(ret!=-1)return ret;
    ret=inf;
    ll sum=0;
    for(int i=x;i<n;i++){
        sum+=a[i];
        if((sum&sum1)==0){
            ret=min(ret,DP(i+1)+1);
        }
    }
    return ret;
}
ll DP1(ll x,ll y){
    if(y>A)return 0;
    if(x==n)return (y<=B);
    ll &ret=dp1[x][y];if(ret!=-1)return ret;
    ret=0;
    ll sum=0;
    for(int i=x;i<n;i++){
        sum+=a[i];
        if((sum&sum1)==0){
            ret=max(ret,DP1(i+1,y+1));
        }
    }
    return ret;
}
int main(){
    cin>>n>>A>>B;
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    if(A==1){
        for(ll i=44;i>=0;i--){
            memset(dp,-1,sizeof(dp));
            sum1+=(1ll<<i);
            if(DP(0)<=B)continue;
            ans+=(1ll<<i);
            sum1-=(1ll<<i);
        }
        cout<<ans<<endl;
        return 0;
    }
    memset(dp1,-1,sizeof(dp1));
    for(ll i=44;i>=0;i--){
        sum1+=(1ll<<i);
        if(DP1(0,0))continue;
        ans+=sum1;
        sum1-=(1ll<<i);
    }
    cout<<ans<<endl;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:38:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%lld",&a[i]);
                                            ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 472 KB Output is correct
9 Correct 1 ms 656 KB Output is correct
10 Correct 1 ms 656 KB Output is correct
11 Correct 2 ms 656 KB Output is correct
12 Correct 1 ms 656 KB Output is correct
13 Correct 2 ms 656 KB Output is correct
14 Incorrect 2 ms 656 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 676 KB Output is correct
2 Correct 1 ms 676 KB Output is correct
3 Correct 1 ms 676 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 1 ms 688 KB Output is correct
6 Correct 1 ms 692 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 700 KB Output is correct
9 Correct 1 ms 700 KB Output is correct
10 Correct 1 ms 708 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 720 KB Output is correct
14 Incorrect 1 ms 724 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 732 KB Output is correct
2 Correct 1 ms 732 KB Output is correct
3 Correct 1 ms 732 KB Output is correct
4 Correct 1 ms 732 KB Output is correct
5 Correct 2 ms 732 KB Output is correct
6 Correct 1 ms 736 KB Output is correct
7 Correct 1 ms 740 KB Output is correct
8 Correct 2 ms 744 KB Output is correct
9 Correct 1 ms 748 KB Output is correct
10 Correct 1 ms 752 KB Output is correct
11 Correct 2 ms 756 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 764 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 1 ms 776 KB Output is correct
17 Correct 2 ms 780 KB Output is correct
18 Correct 2 ms 784 KB Output is correct
19 Correct 2 ms 788 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 796 KB Output is correct
22 Correct 2 ms 800 KB Output is correct
23 Correct 2 ms 800 KB Output is correct
24 Correct 2 ms 804 KB Output is correct
25 Correct 2 ms 812 KB Output is correct
26 Correct 2 ms 816 KB Output is correct
27 Correct 2 ms 820 KB Output is correct
28 Correct 2 ms 824 KB Output is correct
29 Correct 2 ms 836 KB Output is correct
30 Correct 2 ms 836 KB Output is correct
31 Correct 3 ms 840 KB Output is correct
32 Correct 2 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 956 KB Output is correct
2 Correct 2 ms 956 KB Output is correct
3 Correct 1 ms 956 KB Output is correct
4 Correct 2 ms 956 KB Output is correct
5 Correct 2 ms 956 KB Output is correct
6 Correct 1 ms 956 KB Output is correct
7 Correct 2 ms 956 KB Output is correct
8 Correct 2 ms 956 KB Output is correct
9 Correct 2 ms 956 KB Output is correct
10 Correct 2 ms 956 KB Output is correct
11 Correct 2 ms 956 KB Output is correct
12 Correct 2 ms 956 KB Output is correct
13 Correct 2 ms 956 KB Output is correct
14 Incorrect 1 ms 1004 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1004 KB Output is correct
2 Correct 1 ms 1004 KB Output is correct
3 Correct 1 ms 1004 KB Output is correct
4 Correct 1 ms 1004 KB Output is correct
5 Correct 1 ms 1008 KB Output is correct
6 Correct 2 ms 1008 KB Output is correct
7 Correct 1 ms 1008 KB Output is correct
8 Correct 1 ms 1008 KB Output is correct
9 Correct 2 ms 1008 KB Output is correct
10 Correct 1 ms 1008 KB Output is correct
11 Correct 1 ms 1008 KB Output is correct
12 Correct 2 ms 1008 KB Output is correct
13 Correct 1 ms 1008 KB Output is correct
14 Correct 2 ms 1008 KB Output is correct
15 Correct 2 ms 1008 KB Output is correct
16 Correct 1 ms 1008 KB Output is correct
17 Correct 1 ms 1008 KB Output is correct
18 Correct 1 ms 1008 KB Output is correct
19 Correct 1 ms 1008 KB Output is correct
20 Correct 1 ms 1008 KB Output is correct
21 Correct 1 ms 1008 KB Output is correct
22 Correct 1 ms 1008 KB Output is correct
23 Correct 1 ms 1008 KB Output is correct
24 Correct 1 ms 1008 KB Output is correct
25 Correct 2 ms 1008 KB Output is correct
26 Correct 2 ms 1056 KB Output is correct
27 Correct 2 ms 1056 KB Output is correct
28 Correct 2 ms 1056 KB Output is correct
29 Correct 2 ms 1056 KB Output is correct
30 Correct 2 ms 1056 KB Output is correct
31 Correct 2 ms 1056 KB Output is correct
32 Correct 2 ms 1056 KB Output is correct
33 Correct 2 ms 1056 KB Output is correct
34 Correct 2 ms 1056 KB Output is correct
35 Correct 2 ms 1056 KB Output is correct
36 Correct 3 ms 1056 KB Output is correct
37 Correct 2 ms 1064 KB Output is correct
38 Correct 2 ms 1064 KB Output is correct
39 Correct 3 ms 1064 KB Output is correct
40 Correct 2 ms 1064 KB Output is correct
41 Correct 2 ms 1064 KB Output is correct
42 Correct 2 ms 1064 KB Output is correct
43 Correct 2 ms 1064 KB Output is correct
44 Correct 2 ms 1064 KB Output is correct
45 Correct 2 ms 1064 KB Output is correct
46 Correct 2 ms 1064 KB Output is correct
47 Correct 2 ms 1064 KB Output is correct
48 Correct 2 ms 1064 KB Output is correct
49 Correct 2 ms 1064 KB Output is correct
50 Correct 2 ms 1064 KB Output is correct
51 Correct 2 ms 1064 KB Output is correct
52 Correct 11 ms 1064 KB Output is correct
53 Correct 12 ms 1064 KB Output is correct
54 Correct 41 ms 1064 KB Output is correct
55 Correct 30 ms 1140 KB Output is correct
56 Correct 84 ms 1140 KB Output is correct
57 Correct 67 ms 1140 KB Output is correct
58 Correct 86 ms 1140 KB Output is correct
59 Correct 108 ms 1140 KB Output is correct
60 Correct 80 ms 1140 KB Output is correct
61 Correct 2 ms 1140 KB Output is correct
62 Correct 12 ms 1140 KB Output is correct
63 Correct 42 ms 1140 KB Output is correct
64 Correct 19 ms 1140 KB Output is correct
65 Correct 35 ms 1140 KB Output is correct
66 Correct 52 ms 1140 KB Output is correct
67 Correct 72 ms 1140 KB Output is correct
68 Correct 145 ms 1140 KB Output is correct
69 Correct 65 ms 1140 KB Output is correct