# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107894 | 2019-04-26T07:38:11 Z | patrikpavic2 | Bali Sculptures (APIO15_sculpture) | C++17 | 731 ms | 23288 KB |
#include <cstdio> #include <cstring> #include <ctime> #include <cstdlib> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <deque> #define X first #define Y second #define PB push_back using namespace std; typedef long long ll; typedef pair < int, int > pii; typedef vector < int > vi; typedef set < int > si; const int N = 2050; const int M = 105; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const int LOG = 18; const int OFF = (1 << LOG); const double EPS = 1e-9; const double PI = 3.1415926535; ll sum[N][N], ans = 0; int dp[N], A, B, x[N], n, dp2[M][M]; bool check(int k){ for(int i = 0;i < n;i++){ dp[i] = INF; for(int j = -1;j < i;j++){ if((sum[j + 1][i] & (~ans)) < (1LL << k)) dp[i] = min(1 + (j >= 0 ? dp[j] : 0), dp[i]); } } return dp[n - 1] <= B; } bool check2(int k){ memset(dp2, 0, sizeof(dp2)); for(int i = 0;i < n;i++){ for(int j = -1;j < i;j++){ if((sum[j + 1][i] & (~ans)) < (1LL << k)){ if(j == -1){ dp2[i][1] = 1; continue; } for(int k = 1;k <= n;k++){ dp2[i][k] |= dp2[j][k - 1]; } } } } for(int t = A;t <= B;t++) if(dp2[n - 1][t]) return 1; return 0; } int main(){ scanf("%d%d%d", &n, &A, &B); for(int i = 0;i < n;i++) scanf("%d", x + i); for(int i = 0;i < n;i++){ ll cur = 0; for(int j = i;j < n;j++){ cur += (ll)x[j]; sum[i][j] = cur; } } if(n <= 100){ for(int i = 45; i >= 0;i--) if(!check2(i)) ans |= (1LL << i); printf("%lld\n", ans); return 0; } for(int i = 45; i >= 0;i--) if(!check(i)) ans |= (1LL << i); printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 512 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 512 KB | Output is correct |
24 | Correct | 2 ms | 512 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 512 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 3 ms | 512 KB | Output is correct |
30 | Correct | 3 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 3 ms | 512 KB | Output is correct |
33 | Correct | 3 ms | 512 KB | Output is correct |
34 | Correct | 3 ms | 384 KB | Output is correct |
35 | Correct | 3 ms | 384 KB | Output is correct |
36 | Correct | 4 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 512 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 3 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 512 KB | Output is correct |
30 | Correct | 4 ms | 512 KB | Output is correct |
31 | Correct | 5 ms | 640 KB | Output is correct |
32 | Correct | 6 ms | 512 KB | Output is correct |
33 | Correct | 5 ms | 512 KB | Output is correct |
34 | Correct | 5 ms | 640 KB | Output is correct |
35 | Correct | 4 ms | 640 KB | Output is correct |
36 | Correct | 4 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 512 KB | Output is correct |
17 | Correct | 6 ms | 512 KB | Output is correct |
18 | Correct | 4 ms | 640 KB | Output is correct |
19 | Correct | 6 ms | 512 KB | Output is correct |
20 | Correct | 6 ms | 768 KB | Output is correct |
21 | Correct | 5 ms | 640 KB | Output is correct |
22 | Correct | 6 ms | 640 KB | Output is correct |
23 | Correct | 2 ms | 512 KB | Output is correct |
24 | Correct | 6 ms | 640 KB | Output is correct |
25 | Correct | 7 ms | 640 KB | Output is correct |
26 | Correct | 8 ms | 640 KB | Output is correct |
27 | Correct | 17 ms | 768 KB | Output is correct |
28 | Correct | 17 ms | 768 KB | Output is correct |
29 | Correct | 23 ms | 768 KB | Output is correct |
30 | Correct | 24 ms | 768 KB | Output is correct |
31 | Correct | 19 ms | 768 KB | Output is correct |
32 | Correct | 20 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 432 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 512 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 512 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 512 KB | Output is correct |
26 | Correct | 2 ms | 512 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 512 KB | Output is correct |
30 | Correct | 3 ms | 512 KB | Output is correct |
31 | Correct | 2 ms | 520 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 3 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 384 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 3 ms | 512 KB | Output is correct |
37 | Correct | 6 ms | 512 KB | Output is correct |
38 | Correct | 3 ms | 384 KB | Output is correct |
39 | Correct | 4 ms | 512 KB | Output is correct |
40 | Correct | 4 ms | 512 KB | Output is correct |
41 | Correct | 4 ms | 512 KB | Output is correct |
42 | Correct | 4 ms | 640 KB | Output is correct |
43 | Correct | 4 ms | 512 KB | Output is correct |
44 | Correct | 15 ms | 512 KB | Output is correct |
45 | Correct | 5 ms | 640 KB | Output is correct |
46 | Correct | 5 ms | 684 KB | Output is correct |
47 | Correct | 5 ms | 640 KB | Output is correct |
48 | Correct | 13 ms | 640 KB | Output is correct |
49 | Correct | 10 ms | 640 KB | Output is correct |
50 | Correct | 14 ms | 768 KB | Output is correct |
51 | Correct | 15 ms | 768 KB | Output is correct |
52 | Correct | 15 ms | 868 KB | Output is correct |
53 | Correct | 18 ms | 768 KB | Output is correct |
54 | Correct | 19 ms | 768 KB | Output is correct |
55 | Correct | 17 ms | 768 KB | Output is correct |
56 | Correct | 4 ms | 640 KB | Output is correct |
57 | Correct | 8 ms | 640 KB | Output is correct |
58 | Correct | 10 ms | 768 KB | Output is correct |
59 | Correct | 8 ms | 768 KB | Output is correct |
60 | Correct | 7 ms | 768 KB | Output is correct |
61 | Correct | 8 ms | 768 KB | Output is correct |
62 | Correct | 11 ms | 768 KB | Output is correct |
63 | Correct | 13 ms | 768 KB | Output is correct |
64 | Correct | 17 ms | 896 KB | Output is correct |
65 | Correct | 3 ms | 512 KB | Output is correct |
66 | Correct | 5 ms | 640 KB | Output is correct |
67 | Correct | 5 ms | 640 KB | Output is correct |
68 | Correct | 6 ms | 768 KB | Output is correct |
69 | Correct | 8 ms | 768 KB | Output is correct |
70 | Correct | 8 ms | 768 KB | Output is correct |
71 | Correct | 12 ms | 844 KB | Output is correct |
72 | Correct | 9 ms | 768 KB | Output is correct |
73 | Correct | 8 ms | 768 KB | Output is correct |
74 | Correct | 10 ms | 876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 512 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 512 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 512 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 512 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 508 KB | Output is correct |
26 | Correct | 3 ms | 512 KB | Output is correct |
27 | Correct | 5 ms | 512 KB | Output is correct |
28 | Correct | 6 ms | 512 KB | Output is correct |
29 | Correct | 5 ms | 640 KB | Output is correct |
30 | Correct | 5 ms | 640 KB | Output is correct |
31 | Correct | 5 ms | 512 KB | Output is correct |
32 | Correct | 5 ms | 640 KB | Output is correct |
33 | Correct | 6 ms | 640 KB | Output is correct |
34 | Correct | 6 ms | 512 KB | Output is correct |
35 | Correct | 11 ms | 640 KB | Output is correct |
36 | Correct | 8 ms | 640 KB | Output is correct |
37 | Correct | 12 ms | 768 KB | Output is correct |
38 | Correct | 20 ms | 836 KB | Output is correct |
39 | Correct | 14 ms | 768 KB | Output is correct |
40 | Correct | 16 ms | 768 KB | Output is correct |
41 | Correct | 18 ms | 768 KB | Output is correct |
42 | Correct | 18 ms | 768 KB | Output is correct |
43 | Correct | 3 ms | 512 KB | Output is correct |
44 | Correct | 5 ms | 640 KB | Output is correct |
45 | Correct | 6 ms | 768 KB | Output is correct |
46 | Correct | 9 ms | 768 KB | Output is correct |
47 | Correct | 10 ms | 768 KB | Output is correct |
48 | Correct | 8 ms | 768 KB | Output is correct |
49 | Correct | 11 ms | 812 KB | Output is correct |
50 | Correct | 17 ms | 768 KB | Output is correct |
51 | Correct | 3 ms | 768 KB | Output is correct |
52 | Correct | 26 ms | 3968 KB | Output is correct |
53 | Correct | 37 ms | 5680 KB | Output is correct |
54 | Correct | 122 ms | 8320 KB | Output is correct |
55 | Correct | 121 ms | 8312 KB | Output is correct |
56 | Correct | 731 ms | 23160 KB | Output is correct |
57 | Correct | 615 ms | 23168 KB | Output is correct |
58 | Correct | 658 ms | 23248 KB | Output is correct |
59 | Correct | 652 ms | 23168 KB | Output is correct |
60 | Correct | 627 ms | 23260 KB | Output is correct |
61 | Correct | 3 ms | 768 KB | Output is correct |
62 | Correct | 45 ms | 5632 KB | Output is correct |
63 | Correct | 86 ms | 8320 KB | Output is correct |
64 | Correct | 121 ms | 8320 KB | Output is correct |
65 | Correct | 341 ms | 13696 KB | Output is correct |
66 | Correct | 539 ms | 19196 KB | Output is correct |
67 | Correct | 632 ms | 23288 KB | Output is correct |
68 | Correct | 630 ms | 23260 KB | Output is correct |
69 | Correct | 619 ms | 23168 KB | Output is correct |