# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
761285 | 2023-06-19T13:06:02 Z | KN200711 | Bali Sculptures (APIO15_sculpture) | C++14 | 102 ms | 352 KB |
# include <bits/stdc++.h> # define ll long long using namespace std; int N, A, B; ll arr[2001]; int mn[2001]; bool fn(ll a) { for(int i=1;i<=N;i++) mn[i] = 1e9; mn[0] = 0; for(int i=1;i<=N;i++) { ll ad = 0ll; for(int k=i-1;k>=0;k--) { ad += arr[k + 1]; if((ad|a) == a) { if(mn[k] != 1e9) mn[i] = min(mn[i], mn[k] + 1); } } } if(mn[N] <= B) return 1; return 0; } void solve() { ll ls = (1ll << 62) - 1ll; for(int i=61;i>=0;i--) { ll P = ls - (1ll << i); if(fn(P)) { ls = P; } } printf("%lld\n", ls); } bool dp[201][201]; bool cek(ll P) { for(int c=0;c<=200;c++) { for(int d=0;d<=200;d++) { dp[c][d] = 0; } } dp[0][0] = 1; for(int k=1;k<=N;k++) { ll ad = 0ll; for(int c=k-1;c>=0;c--) { ad += arr[c + 1]; if((ad|P) == P) { for(int l=0;l<B;l++) { if(dp[c][l]) dp[k][l+1] = 1; } } } } for(int i=A;i<=B;i++) { if(dp[N][i]) return 1; } return 0; } void ans() { ll ls = (1ll << 62) - 1ll; for(int i=61;i>=0;i--) { // cek bit ini bisa atau ngga ll P = ls - (1ll << i); if(cek(P)) { ls = P; } } printf("%lld\n", ls); } int main() { scanf("%d %d %d", &N, &A, &B); for(int i=1;i<=N;i++) scanf("%lld", &arr[i]); if(A == 1) solve(); else ans(); // cout<<cek(9)<<endl; }
Compilation message
# | 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 | 1 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 | 304 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 304 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 304 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 304 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 300 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 304 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 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 | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 308 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 1 ms | 300 KB | Output is correct |
# | 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 | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 308 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 300 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 308 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 304 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 352 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 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 | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 212 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 1 ms | 212 KB | Output is correct |
# | 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 | 216 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 304 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 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 | 300 KB | Output is correct |
17 | Correct | 1 ms | 300 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 300 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 300 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 300 KB | Output is correct |
28 | Correct | 1 ms | 300 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 300 KB | Output is correct |
19 | Correct | 1 ms | 308 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 304 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 300 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 0 ms | 212 KB | Output is correct |
36 | Correct | 0 ms | 304 KB | Output is correct |
37 | Correct | 1 ms | 308 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 1 ms | 212 KB | Output is correct |
40 | Correct | 1 ms | 212 KB | Output is correct |
41 | Correct | 1 ms | 304 KB | Output is correct |
42 | Correct | 1 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 212 KB | Output is correct |
44 | Correct | 1 ms | 212 KB | Output is correct |
45 | Correct | 1 ms | 212 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 1 ms | 300 KB | Output is correct |
48 | Correct | 1 ms | 340 KB | Output is correct |
49 | Correct | 1 ms | 212 KB | Output is correct |
50 | Correct | 1 ms | 212 KB | Output is correct |
51 | Correct | 1 ms | 212 KB | Output is correct |
52 | Correct | 1 ms | 212 KB | Output is correct |
53 | Correct | 1 ms | 304 KB | Output is correct |
54 | Correct | 1 ms | 212 KB | Output is correct |
55 | Correct | 1 ms | 212 KB | Output is correct |
56 | Correct | 1 ms | 212 KB | Output is correct |
57 | Correct | 1 ms | 212 KB | Output is correct |
58 | Correct | 1 ms | 212 KB | Output is correct |
59 | Correct | 1 ms | 212 KB | Output is correct |
60 | Correct | 1 ms | 212 KB | Output is correct |
61 | Correct | 1 ms | 212 KB | Output is correct |
62 | Correct | 1 ms | 212 KB | Output is correct |
63 | Correct | 1 ms | 212 KB | Output is correct |
64 | Correct | 20 ms | 304 KB | Output is correct |
65 | Correct | 1 ms | 340 KB | Output is correct |
66 | Correct | 1 ms | 340 KB | Output is correct |
67 | Correct | 2 ms | 344 KB | Output is correct |
68 | Correct | 7 ms | 340 KB | Output is correct |
69 | Correct | 13 ms | 340 KB | Output is correct |
70 | Correct | 13 ms | 340 KB | Output is correct |
71 | Correct | 1 ms | 340 KB | Output is correct |
72 | Correct | 14 ms | 348 KB | Output is correct |
73 | Correct | 12 ms | 340 KB | Output is correct |
74 | Correct | 10 ms | 304 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 | 0 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 | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 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 | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 304 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 244 KB | Output is correct |
28 | Correct | 1 ms | 224 KB | Output is correct |
29 | Correct | 1 ms | 224 KB | Output is correct |
30 | Correct | 1 ms | 224 KB | Output is correct |
31 | Correct | 1 ms | 224 KB | Output is correct |
32 | Correct | 1 ms | 224 KB | Output is correct |
33 | Correct | 1 ms | 224 KB | Output is correct |
34 | Correct | 1 ms | 224 KB | Output is correct |
35 | Correct | 1 ms | 224 KB | Output is correct |
36 | Correct | 1 ms | 316 KB | Output is correct |
37 | Correct | 1 ms | 224 KB | Output is correct |
38 | Correct | 1 ms | 224 KB | Output is correct |
39 | Correct | 1 ms | 224 KB | Output is correct |
40 | Correct | 1 ms | 224 KB | Output is correct |
41 | Correct | 1 ms | 224 KB | Output is correct |
42 | Correct | 1 ms | 224 KB | Output is correct |
43 | Correct | 1 ms | 224 KB | Output is correct |
44 | Correct | 1 ms | 224 KB | Output is correct |
45 | Correct | 1 ms | 312 KB | Output is correct |
46 | Correct | 1 ms | 312 KB | Output is correct |
47 | Correct | 1 ms | 224 KB | Output is correct |
48 | Correct | 1 ms | 224 KB | Output is correct |
49 | Correct | 1 ms | 320 KB | Output is correct |
50 | Correct | 1 ms | 224 KB | Output is correct |
51 | Correct | 1 ms | 224 KB | Output is correct |
52 | Correct | 9 ms | 320 KB | Output is correct |
53 | Correct | 14 ms | 224 KB | Output is correct |
54 | Correct | 27 ms | 224 KB | Output is correct |
55 | Correct | 25 ms | 224 KB | Output is correct |
56 | Correct | 97 ms | 352 KB | Output is correct |
57 | Correct | 96 ms | 320 KB | Output is correct |
58 | Correct | 94 ms | 340 KB | Output is correct |
59 | Correct | 102 ms | 340 KB | Output is correct |
60 | Correct | 98 ms | 336 KB | Output is correct |
61 | Correct | 1 ms | 212 KB | Output is correct |
62 | Correct | 15 ms | 316 KB | Output is correct |
63 | Correct | 27 ms | 332 KB | Output is correct |
64 | Correct | 25 ms | 212 KB | Output is correct |
65 | Correct | 48 ms | 320 KB | Output is correct |
66 | Correct | 73 ms | 328 KB | Output is correct |
67 | Correct | 100 ms | 336 KB | Output is correct |
68 | Correct | 100 ms | 212 KB | Output is correct |
69 | Correct | 96 ms | 212 KB | Output is correct |