Submission #41697

# Submission time Handle Problem Language Result Execution time Memory
41697 2018-02-20T18:54:08 Z Hassoony Bali Sculptures (APIO15_sculpture) C++14
100 / 100
172 ms 1152 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>B)return 0;
    if(x==n)return (y>=A);
    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=48;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;
    }
    for(ll i=48;i>=0;i--){
        sum1+=(1ll<<i);
        memset(dp1,-1,sizeof(dp1));
        if(DP1(0,0)!=0)continue;
        ans+=(1ll<<i);
        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 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 424 KB Output is correct
4 Correct 1 ms 440 KB Output is correct
5 Correct 1 ms 440 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 1 ms 644 KB Output is correct
9 Correct 2 ms 644 KB Output is correct
10 Correct 1 ms 644 KB Output is correct
11 Correct 1 ms 644 KB Output is correct
12 Correct 1 ms 668 KB Output is correct
13 Correct 2 ms 668 KB Output is correct
14 Correct 2 ms 668 KB Output is correct
15 Correct 2 ms 668 KB Output is correct
16 Correct 2 ms 680 KB Output is correct
17 Correct 2 ms 680 KB Output is correct
18 Correct 2 ms 680 KB Output is correct
19 Correct 2 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 680 KB Output is correct
22 Correct 2 ms 680 KB Output is correct
23 Correct 2 ms 680 KB Output is correct
24 Correct 2 ms 680 KB Output is correct
25 Correct 2 ms 680 KB Output is correct
26 Correct 2 ms 680 KB Output is correct
27 Correct 1 ms 680 KB Output is correct
28 Correct 1 ms 680 KB Output is correct
29 Correct 2 ms 680 KB Output is correct
30 Correct 2 ms 680 KB Output is correct
31 Correct 1 ms 684 KB Output is correct
32 Correct 1 ms 688 KB Output is correct
33 Correct 1 ms 696 KB Output is correct
34 Correct 1 ms 696 KB Output is correct
35 Correct 1 ms 704 KB Output is correct
36 Correct 1 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 828 KB Output is correct
2 Correct 1 ms 828 KB Output is correct
3 Correct 1 ms 828 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 1 ms 828 KB Output is correct
6 Correct 2 ms 828 KB Output is correct
7 Correct 2 ms 828 KB Output is correct
8 Correct 2 ms 828 KB Output is correct
9 Correct 1 ms 828 KB Output is correct
10 Correct 2 ms 828 KB Output is correct
11 Correct 1 ms 828 KB Output is correct
12 Correct 1 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 828 KB Output is correct
18 Correct 2 ms 828 KB Output is correct
19 Correct 2 ms 828 KB Output is correct
20 Correct 2 ms 828 KB Output is correct
21 Correct 3 ms 828 KB Output is correct
22 Correct 2 ms 828 KB Output is correct
23 Correct 2 ms 828 KB Output is correct
24 Correct 2 ms 828 KB Output is correct
25 Correct 2 ms 828 KB Output is correct
26 Correct 3 ms 828 KB Output is correct
27 Correct 2 ms 828 KB Output is correct
28 Correct 2 ms 828 KB Output is correct
29 Correct 2 ms 828 KB Output is correct
30 Correct 2 ms 828 KB Output is correct
31 Correct 2 ms 828 KB Output is correct
32 Correct 2 ms 828 KB Output is correct
33 Correct 2 ms 828 KB Output is correct
34 Correct 2 ms 892 KB Output is correct
35 Correct 2 ms 892 KB Output is correct
36 Correct 2 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 892 KB Output is correct
2 Correct 1 ms 892 KB Output is correct
3 Correct 1 ms 892 KB Output is correct
4 Correct 2 ms 892 KB Output is correct
5 Correct 1 ms 892 KB Output is correct
6 Correct 2 ms 920 KB Output is correct
7 Correct 1 ms 920 KB Output is correct
8 Correct 2 ms 920 KB Output is correct
9 Correct 2 ms 920 KB Output is correct
10 Correct 2 ms 920 KB Output is correct
11 Correct 2 ms 920 KB Output is correct
12 Correct 1 ms 920 KB Output is correct
13 Correct 1 ms 920 KB Output is correct
14 Correct 1 ms 920 KB Output is correct
15 Correct 1 ms 920 KB Output is correct
16 Correct 2 ms 920 KB Output is correct
17 Correct 2 ms 920 KB Output is correct
18 Correct 2 ms 920 KB Output is correct
19 Correct 2 ms 920 KB Output is correct
20 Correct 2 ms 920 KB Output is correct
21 Correct 2 ms 920 KB Output is correct
22 Correct 2 ms 920 KB Output is correct
23 Correct 2 ms 920 KB Output is correct
24 Correct 2 ms 920 KB Output is correct
25 Correct 2 ms 920 KB Output is correct
26 Correct 2 ms 920 KB Output is correct
27 Correct 2 ms 920 KB Output is correct
28 Correct 2 ms 920 KB Output is correct
29 Correct 2 ms 920 KB Output is correct
30 Correct 3 ms 920 KB Output is correct
31 Correct 2 ms 920 KB Output is correct
32 Correct 2 ms 920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 920 KB Output is correct
2 Correct 2 ms 920 KB Output is correct
3 Correct 2 ms 920 KB Output is correct
4 Correct 2 ms 920 KB Output is correct
5 Correct 2 ms 920 KB Output is correct
6 Correct 2 ms 920 KB Output is correct
7 Correct 1 ms 920 KB Output is correct
8 Correct 1 ms 920 KB Output is correct
9 Correct 2 ms 920 KB Output is correct
10 Correct 2 ms 920 KB Output is correct
11 Correct 1 ms 920 KB Output is correct
12 Correct 2 ms 920 KB Output is correct
13 Correct 1 ms 920 KB Output is correct
14 Correct 2 ms 920 KB Output is correct
15 Correct 2 ms 920 KB Output is correct
16 Correct 2 ms 920 KB Output is correct
17 Correct 2 ms 920 KB Output is correct
18 Correct 2 ms 920 KB Output is correct
19 Correct 2 ms 920 KB Output is correct
20 Correct 2 ms 920 KB Output is correct
21 Correct 2 ms 920 KB Output is correct
22 Correct 2 ms 920 KB Output is correct
23 Correct 2 ms 920 KB Output is correct
24 Correct 2 ms 920 KB Output is correct
25 Correct 3 ms 920 KB Output is correct
26 Correct 2 ms 920 KB Output is correct
27 Correct 1 ms 920 KB Output is correct
28 Correct 2 ms 920 KB Output is correct
29 Correct 2 ms 920 KB Output is correct
30 Correct 2 ms 920 KB Output is correct
31 Correct 2 ms 920 KB Output is correct
32 Correct 2 ms 920 KB Output is correct
33 Correct 2 ms 976 KB Output is correct
34 Correct 2 ms 976 KB Output is correct
35 Correct 2 ms 976 KB Output is correct
36 Correct 2 ms 976 KB Output is correct
37 Correct 2 ms 976 KB Output is correct
38 Correct 2 ms 976 KB Output is correct
39 Correct 2 ms 976 KB Output is correct
40 Correct 2 ms 976 KB Output is correct
41 Correct 2 ms 976 KB Output is correct
42 Correct 2 ms 976 KB Output is correct
43 Correct 2 ms 976 KB Output is correct
44 Correct 2 ms 976 KB Output is correct
45 Correct 2 ms 976 KB Output is correct
46 Correct 2 ms 976 KB Output is correct
47 Correct 2 ms 1024 KB Output is correct
48 Correct 2 ms 1024 KB Output is correct
49 Correct 2 ms 1024 KB Output is correct
50 Correct 2 ms 1024 KB Output is correct
51 Correct 3 ms 1024 KB Output is correct
52 Correct 3 ms 1024 KB Output is correct
53 Correct 2 ms 1024 KB Output is correct
54 Correct 3 ms 1024 KB Output is correct
55 Correct 3 ms 1024 KB Output is correct
56 Correct 2 ms 1024 KB Output is correct
57 Correct 2 ms 1024 KB Output is correct
58 Correct 2 ms 1024 KB Output is correct
59 Correct 2 ms 1024 KB Output is correct
60 Correct 2 ms 1024 KB Output is correct
61 Correct 2 ms 1024 KB Output is correct
62 Correct 2 ms 1024 KB Output is correct
63 Correct 2 ms 1024 KB Output is correct
64 Correct 35 ms 1024 KB Output is correct
65 Correct 5 ms 1024 KB Output is correct
66 Correct 4 ms 1024 KB Output is correct
67 Correct 8 ms 1116 KB Output is correct
68 Correct 17 ms 1120 KB Output is correct
69 Correct 21 ms 1120 KB Output is correct
70 Correct 19 ms 1120 KB Output is correct
71 Correct 3 ms 1120 KB Output is correct
72 Correct 23 ms 1120 KB Output is correct
73 Correct 21 ms 1120 KB Output is correct
74 Correct 20 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1120 KB Output is correct
2 Correct 2 ms 1120 KB Output is correct
3 Correct 2 ms 1120 KB Output is correct
4 Correct 2 ms 1120 KB Output is correct
5 Correct 1 ms 1120 KB Output is correct
6 Correct 2 ms 1120 KB Output is correct
7 Correct 2 ms 1120 KB Output is correct
8 Correct 2 ms 1120 KB Output is correct
9 Correct 2 ms 1120 KB Output is correct
10 Correct 2 ms 1120 KB Output is correct
11 Correct 2 ms 1120 KB Output is correct
12 Correct 2 ms 1120 KB Output is correct
13 Correct 2 ms 1120 KB Output is correct
14 Correct 2 ms 1120 KB Output is correct
15 Correct 2 ms 1120 KB Output is correct
16 Correct 2 ms 1120 KB Output is correct
17 Correct 2 ms 1120 KB Output is correct
18 Correct 2 ms 1120 KB Output is correct
19 Correct 2 ms 1120 KB Output is correct
20 Correct 2 ms 1120 KB Output is correct
21 Correct 2 ms 1120 KB Output is correct
22 Correct 2 ms 1120 KB Output is correct
23 Correct 2 ms 1120 KB Output is correct
24 Correct 2 ms 1120 KB Output is correct
25 Correct 2 ms 1120 KB Output is correct
26 Correct 2 ms 1120 KB Output is correct
27 Correct 2 ms 1120 KB Output is correct
28 Correct 2 ms 1120 KB Output is correct
29 Correct 2 ms 1120 KB Output is correct
30 Correct 2 ms 1120 KB Output is correct
31 Correct 2 ms 1120 KB Output is correct
32 Correct 2 ms 1120 KB Output is correct
33 Correct 2 ms 1128 KB Output is correct
34 Correct 2 ms 1128 KB Output is correct
35 Correct 2 ms 1128 KB Output is correct
36 Correct 2 ms 1128 KB Output is correct
37 Correct 2 ms 1148 KB Output is correct
38 Correct 2 ms 1148 KB Output is correct
39 Correct 2 ms 1148 KB Output is correct
40 Correct 2 ms 1148 KB Output is correct
41 Correct 2 ms 1148 KB Output is correct
42 Correct 2 ms 1148 KB Output is correct
43 Correct 2 ms 1148 KB Output is correct
44 Correct 2 ms 1148 KB Output is correct
45 Correct 2 ms 1148 KB Output is correct
46 Correct 2 ms 1148 KB Output is correct
47 Correct 2 ms 1148 KB Output is correct
48 Correct 2 ms 1148 KB Output is correct
49 Correct 3 ms 1148 KB Output is correct
50 Correct 2 ms 1148 KB Output is correct
51 Correct 2 ms 1148 KB Output is correct
52 Correct 14 ms 1148 KB Output is correct
53 Correct 15 ms 1148 KB Output is correct
54 Correct 57 ms 1148 KB Output is correct
55 Correct 41 ms 1148 KB Output is correct
56 Correct 99 ms 1148 KB Output is correct
57 Correct 94 ms 1148 KB Output is correct
58 Correct 123 ms 1152 KB Output is correct
59 Correct 132 ms 1152 KB Output is correct
60 Correct 107 ms 1152 KB Output is correct
61 Correct 2 ms 1152 KB Output is correct
62 Correct 16 ms 1152 KB Output is correct
63 Correct 53 ms 1152 KB Output is correct
64 Correct 25 ms 1152 KB Output is correct
65 Correct 58 ms 1152 KB Output is correct
66 Correct 71 ms 1152 KB Output is correct
67 Correct 93 ms 1152 KB Output is correct
68 Correct 172 ms 1152 KB Output is correct
69 Correct 90 ms 1152 KB Output is correct