Submission #443771

# Submission time Handle Problem Language Result Execution time Memory
443771 2021-07-12T04:36:18 Z impri Bali Sculptures (APIO15_sculpture) C++14
100 / 100
221 ms 16244 KB
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int arr[2001];
int dp[2002][2011];
int place;
long long res=0;
int get(int cur,int r){
    if(cur==n+1){
        if(a<=r && r<=b)return 1;
        return 0;
    }
if(dp[cur][r]!=-1)return dp[cur][r];
long long sum=0;
int ok=0;
for(int i=cur;i<=n;i++){
    sum+=arr[i];
    if((res >> (place+1))==((res|sum) >> (place+1))){
        if((sum & (1LL << place))==0)
        ok=max(ok,get(i+1,r+1));
    }

}
return dp[cur][r]=ok;
}
int get2(int cur){
if(cur==n+1)return 0;
if(dp[cur][0]!=-1)return dp[cur][0];
long long sum=0;
int r=100000;
for(int i=cur;i<=n;i++){
    sum+=arr[i];
    if((res >> (place+1))==((res|sum) >> (place+1))){
        if((sum & (1LL << place))==0)
        r=min(r,1+get2(i+1));
    }

}
return dp[cur][0]=r;
}
int main(void){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
cin >>n >> a >> b;
for(int i=1;i<=n;i++)
    cin >> arr[i];
if(a>1){
for(place=40;place>=0;place--){
    memset(dp,-1,sizeof(dp));
    if(!get(1,0)){
        res+=(1LL << place);
    }

}
cout << res;
}
else{
    for(place=40;place>=0;place--){
    memset(dp,-1,sizeof(dp));
    if(get2(1)>b){
        res+=(1LL << place);
    }


}
cout << res;
}
}
# Verdict Execution time Memory Grader output
1 Correct 84 ms 16044 KB Output is correct
2 Correct 81 ms 16076 KB Output is correct
3 Correct 82 ms 15948 KB Output is correct
4 Correct 82 ms 15948 KB Output is correct
5 Correct 82 ms 16056 KB Output is correct
6 Correct 84 ms 15948 KB Output is correct
7 Correct 84 ms 16052 KB Output is correct
8 Correct 81 ms 16056 KB Output is correct
9 Correct 85 ms 16048 KB Output is correct
10 Correct 82 ms 16032 KB Output is correct
11 Correct 84 ms 15948 KB Output is correct
12 Correct 85 ms 15948 KB Output is correct
13 Correct 83 ms 16060 KB Output is correct
14 Correct 82 ms 16076 KB Output is correct
15 Correct 84 ms 16056 KB Output is correct
16 Correct 84 ms 15948 KB Output is correct
17 Correct 84 ms 16076 KB Output is correct
18 Correct 85 ms 16060 KB Output is correct
19 Correct 84 ms 16076 KB Output is correct
20 Correct 85 ms 15948 KB Output is correct
21 Correct 82 ms 16068 KB Output is correct
22 Correct 85 ms 15948 KB Output is correct
23 Correct 85 ms 15948 KB Output is correct
24 Correct 81 ms 16076 KB Output is correct
25 Correct 82 ms 16052 KB Output is correct
26 Correct 84 ms 16076 KB Output is correct
27 Correct 83 ms 16076 KB Output is correct
28 Correct 83 ms 16076 KB Output is correct
29 Correct 81 ms 16052 KB Output is correct
30 Correct 82 ms 16076 KB Output is correct
31 Correct 85 ms 15948 KB Output is correct
32 Correct 85 ms 16024 KB Output is correct
33 Correct 83 ms 16076 KB Output is correct
34 Correct 83 ms 16204 KB Output is correct
35 Correct 82 ms 16076 KB Output is correct
36 Correct 82 ms 15948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 15948 KB Output is correct
2 Correct 84 ms 16076 KB Output is correct
3 Correct 82 ms 16052 KB Output is correct
4 Correct 86 ms 15948 KB Output is correct
5 Correct 84 ms 15976 KB Output is correct
6 Correct 83 ms 16076 KB Output is correct
7 Correct 84 ms 16056 KB Output is correct
8 Correct 86 ms 16076 KB Output is correct
9 Correct 89 ms 16064 KB Output is correct
10 Correct 85 ms 16020 KB Output is correct
11 Correct 85 ms 16056 KB Output is correct
12 Correct 83 ms 16056 KB Output is correct
13 Correct 85 ms 16064 KB Output is correct
14 Correct 85 ms 15948 KB Output is correct
15 Correct 83 ms 16076 KB Output is correct
16 Correct 89 ms 15948 KB Output is correct
17 Correct 86 ms 15948 KB Output is correct
18 Correct 82 ms 15948 KB Output is correct
19 Correct 85 ms 16052 KB Output is correct
20 Correct 83 ms 15948 KB Output is correct
21 Correct 86 ms 16060 KB Output is correct
22 Correct 83 ms 15948 KB Output is correct
23 Correct 84 ms 16056 KB Output is correct
24 Correct 84 ms 16068 KB Output is correct
25 Correct 84 ms 16024 KB Output is correct
26 Correct 85 ms 15948 KB Output is correct
27 Correct 84 ms 16052 KB Output is correct
28 Correct 84 ms 15948 KB Output is correct
29 Correct 83 ms 15948 KB Output is correct
30 Correct 83 ms 16056 KB Output is correct
31 Correct 84 ms 15968 KB Output is correct
32 Correct 83 ms 15948 KB Output is correct
33 Correct 85 ms 15948 KB Output is correct
34 Correct 83 ms 15948 KB Output is correct
35 Correct 86 ms 16076 KB Output is correct
36 Correct 82 ms 15976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 16052 KB Output is correct
2 Correct 82 ms 15948 KB Output is correct
3 Correct 84 ms 16068 KB Output is correct
4 Correct 85 ms 16052 KB Output is correct
5 Correct 84 ms 16076 KB Output is correct
6 Correct 84 ms 16056 KB Output is correct
7 Correct 85 ms 16056 KB Output is correct
8 Correct 83 ms 15948 KB Output is correct
9 Correct 85 ms 16056 KB Output is correct
10 Correct 83 ms 16056 KB Output is correct
11 Correct 85 ms 16056 KB Output is correct
12 Correct 82 ms 15948 KB Output is correct
13 Correct 83 ms 16052 KB Output is correct
14 Correct 83 ms 15948 KB Output is correct
15 Correct 86 ms 16060 KB Output is correct
16 Correct 82 ms 15948 KB Output is correct
17 Correct 82 ms 15948 KB Output is correct
18 Correct 83 ms 16056 KB Output is correct
19 Correct 88 ms 16056 KB Output is correct
20 Correct 86 ms 16076 KB Output is correct
21 Correct 83 ms 15948 KB Output is correct
22 Correct 82 ms 16076 KB Output is correct
23 Correct 85 ms 16056 KB Output is correct
24 Correct 83 ms 16052 KB Output is correct
25 Correct 83 ms 15948 KB Output is correct
26 Correct 84 ms 16056 KB Output is correct
27 Correct 87 ms 16076 KB Output is correct
28 Correct 83 ms 15996 KB Output is correct
29 Correct 83 ms 16076 KB Output is correct
30 Correct 83 ms 16056 KB Output is correct
31 Correct 83 ms 16076 KB Output is correct
32 Correct 82 ms 15972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 16076 KB Output is correct
2 Correct 85 ms 16032 KB Output is correct
3 Correct 87 ms 15948 KB Output is correct
4 Correct 90 ms 16056 KB Output is correct
5 Correct 84 ms 15948 KB Output is correct
6 Correct 83 ms 16040 KB Output is correct
7 Correct 88 ms 15948 KB Output is correct
8 Correct 83 ms 16052 KB Output is correct
9 Correct 86 ms 16052 KB Output is correct
10 Correct 86 ms 15968 KB Output is correct
11 Correct 85 ms 16068 KB Output is correct
12 Correct 86 ms 15948 KB Output is correct
13 Correct 85 ms 15948 KB Output is correct
14 Correct 86 ms 15948 KB Output is correct
15 Correct 84 ms 16076 KB Output is correct
16 Correct 82 ms 16056 KB Output is correct
17 Correct 84 ms 16076 KB Output is correct
18 Correct 83 ms 16076 KB Output is correct
19 Correct 82 ms 15948 KB Output is correct
20 Correct 85 ms 15948 KB Output is correct
21 Correct 85 ms 16056 KB Output is correct
22 Correct 86 ms 15948 KB Output is correct
23 Correct 86 ms 16072 KB Output is correct
24 Correct 85 ms 16064 KB Output is correct
25 Correct 83 ms 15948 KB Output is correct
26 Correct 83 ms 15948 KB Output is correct
27 Correct 83 ms 16052 KB Output is correct
28 Correct 83 ms 16068 KB Output is correct
29 Correct 83 ms 16068 KB Output is correct
30 Correct 83 ms 15948 KB Output is correct
31 Correct 85 ms 15948 KB Output is correct
32 Correct 83 ms 15948 KB Output is correct
33 Correct 85 ms 16064 KB Output is correct
34 Correct 84 ms 15948 KB Output is correct
35 Correct 83 ms 16056 KB Output is correct
36 Correct 83 ms 15948 KB Output is correct
37 Correct 84 ms 16076 KB Output is correct
38 Correct 83 ms 16052 KB Output is correct
39 Correct 85 ms 15948 KB Output is correct
40 Correct 84 ms 15948 KB Output is correct
41 Correct 84 ms 15948 KB Output is correct
42 Correct 84 ms 16064 KB Output is correct
43 Correct 84 ms 16076 KB Output is correct
44 Correct 83 ms 15948 KB Output is correct
45 Correct 82 ms 16052 KB Output is correct
46 Correct 85 ms 15976 KB Output is correct
47 Correct 83 ms 16076 KB Output is correct
48 Correct 83 ms 16012 KB Output is correct
49 Correct 84 ms 15948 KB Output is correct
50 Correct 87 ms 16056 KB Output is correct
51 Correct 84 ms 15948 KB Output is correct
52 Correct 83 ms 15948 KB Output is correct
53 Correct 88 ms 16176 KB Output is correct
54 Correct 87 ms 16076 KB Output is correct
55 Correct 85 ms 16068 KB Output is correct
56 Correct 85 ms 16068 KB Output is correct
57 Correct 82 ms 15948 KB Output is correct
58 Correct 85 ms 15948 KB Output is correct
59 Correct 85 ms 15980 KB Output is correct
60 Correct 84 ms 16024 KB Output is correct
61 Correct 84 ms 16076 KB Output is correct
62 Correct 83 ms 16076 KB Output is correct
63 Correct 88 ms 16076 KB Output is correct
64 Correct 114 ms 16056 KB Output is correct
65 Correct 84 ms 15948 KB Output is correct
66 Correct 88 ms 16124 KB Output is correct
67 Correct 92 ms 16068 KB Output is correct
68 Correct 89 ms 16076 KB Output is correct
69 Correct 92 ms 16076 KB Output is correct
70 Correct 93 ms 16028 KB Output is correct
71 Correct 95 ms 16076 KB Output is correct
72 Correct 97 ms 15948 KB Output is correct
73 Correct 96 ms 16056 KB Output is correct
74 Correct 96 ms 15948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 16056 KB Output is correct
2 Correct 84 ms 16056 KB Output is correct
3 Correct 85 ms 16076 KB Output is correct
4 Correct 85 ms 15992 KB Output is correct
5 Correct 86 ms 15980 KB Output is correct
6 Correct 84 ms 15948 KB Output is correct
7 Correct 84 ms 16056 KB Output is correct
8 Correct 83 ms 15948 KB Output is correct
9 Correct 84 ms 15948 KB Output is correct
10 Correct 86 ms 16076 KB Output is correct
11 Correct 85 ms 15948 KB Output is correct
12 Correct 83 ms 16056 KB Output is correct
13 Correct 87 ms 15948 KB Output is correct
14 Correct 85 ms 16204 KB Output is correct
15 Correct 83 ms 16056 KB Output is correct
16 Correct 84 ms 15948 KB Output is correct
17 Correct 85 ms 15948 KB Output is correct
18 Correct 84 ms 15948 KB Output is correct
19 Correct 85 ms 16056 KB Output is correct
20 Correct 83 ms 15948 KB Output is correct
21 Correct 81 ms 16056 KB Output is correct
22 Correct 83 ms 16056 KB Output is correct
23 Correct 86 ms 15948 KB Output is correct
24 Correct 84 ms 16052 KB Output is correct
25 Correct 87 ms 16056 KB Output is correct
26 Correct 82 ms 15948 KB Output is correct
27 Correct 82 ms 15948 KB Output is correct
28 Correct 83 ms 16052 KB Output is correct
29 Correct 83 ms 15948 KB Output is correct
30 Correct 82 ms 16068 KB Output is correct
31 Correct 87 ms 16076 KB Output is correct
32 Correct 81 ms 15948 KB Output is correct
33 Correct 83 ms 15948 KB Output is correct
34 Correct 82 ms 16076 KB Output is correct
35 Correct 86 ms 16056 KB Output is correct
36 Correct 82 ms 15948 KB Output is correct
37 Correct 82 ms 16068 KB Output is correct
38 Correct 86 ms 16060 KB Output is correct
39 Correct 84 ms 16076 KB Output is correct
40 Correct 83 ms 15948 KB Output is correct
41 Correct 88 ms 16076 KB Output is correct
42 Correct 89 ms 16076 KB Output is correct
43 Correct 85 ms 15948 KB Output is correct
44 Correct 83 ms 15948 KB Output is correct
45 Correct 84 ms 16076 KB Output is correct
46 Correct 85 ms 16056 KB Output is correct
47 Correct 85 ms 15948 KB Output is correct
48 Correct 88 ms 16076 KB Output is correct
49 Correct 84 ms 16076 KB Output is correct
50 Correct 89 ms 16076 KB Output is correct
51 Correct 84 ms 16076 KB Output is correct
52 Correct 94 ms 16044 KB Output is correct
53 Correct 92 ms 16136 KB Output is correct
54 Correct 121 ms 16152 KB Output is correct
55 Correct 108 ms 16140 KB Output is correct
56 Correct 138 ms 16236 KB Output is correct
57 Correct 130 ms 16204 KB Output is correct
58 Correct 141 ms 16240 KB Output is correct
59 Correct 170 ms 16244 KB Output is correct
60 Correct 145 ms 16236 KB Output is correct
61 Correct 83 ms 16076 KB Output is correct
62 Correct 91 ms 16076 KB Output is correct
63 Correct 123 ms 16076 KB Output is correct
64 Correct 93 ms 16076 KB Output is correct
65 Correct 109 ms 16188 KB Output is correct
66 Correct 122 ms 16220 KB Output is correct
67 Correct 131 ms 16236 KB Output is correct
68 Correct 221 ms 16244 KB Output is correct
69 Correct 125 ms 16204 KB Output is correct