# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78030 | 2018-10-02T00:55:03 Z | xiaowuc1 | Bali Sculptures (APIO15_sculpture) | C++14 | 572 ms | 1160 KB |
#include <bits/stdc++.h> /* unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count(); mt19937 g1.seed(seed1); ios_base::sync_with_stdio(false); cin.tie(NULL); */ using namespace std; const double PI = 2 * acos(0); typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<int, ll> pill; typedef pair<ll, ll> pll; typedef long double ld; typedef vector<vector<ll>> matrix; ll pref[2001]; int n, lhs, rhs; bool valid[2001]; bool nextValid[2001]; bitset<2001> dp[2001]; bool can(ll mask) { for(int i = 0; i <= n; i++) { dp[i].reset(); } dp[0].set(0); for(int i = 0; i < n; i++) { for(int j = i+1; j <= n; j++) { ll vv = pref[j] - pref[i]; if((vv&mask)!=vv) continue; dp[j] |= (dp[i] << 1); } } for(int x = lhs; x <= rhs; x++) { if(dp[n][x]) return true; } return false; } int main() { scanf("%d%d%d", &n, &lhs, &rhs); for(int i = 0; i < n; i++) { scanf("%lld", &pref[i+1]); pref[i+1] += pref[i]; } ll ret = 1; while(ret < pref[n]) { ret |= ret << 1; } for(int i = 45; i >= 0; i--) { ll ans = ret & ~(1LL << (i)); if(ans == ret) continue; if(can(ans)) { ret = ans; } } printf("%lld\n", ret); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 472 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 2 ms | 472 KB | Output is correct |
5 | Correct | 2 ms | 516 KB | Output is correct |
6 | Correct | 2 ms | 516 KB | Output is correct |
7 | Correct | 2 ms | 516 KB | Output is correct |
8 | Correct | 2 ms | 572 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 2 ms | 592 KB | Output is correct |
11 | Correct | 2 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 592 KB | Output is correct |
13 | Correct | 2 ms | 620 KB | Output is correct |
14 | Correct | 2 ms | 636 KB | Output is correct |
15 | Correct | 2 ms | 636 KB | Output is correct |
16 | Correct | 2 ms | 636 KB | Output is correct |
17 | Correct | 2 ms | 636 KB | Output is correct |
18 | Correct | 2 ms | 636 KB | Output is correct |
19 | Correct | 2 ms | 636 KB | Output is correct |
20 | Correct | 2 ms | 640 KB | Output is correct |
21 | Correct | 2 ms | 640 KB | Output is correct |
22 | Correct | 2 ms | 640 KB | Output is correct |
23 | Correct | 2 ms | 640 KB | Output is correct |
24 | Correct | 2 ms | 640 KB | Output is correct |
25 | Correct | 2 ms | 640 KB | Output is correct |
26 | Correct | 2 ms | 640 KB | Output is correct |
27 | Correct | 2 ms | 640 KB | Output is correct |
28 | Correct | 2 ms | 640 KB | Output is correct |
29 | Correct | 2 ms | 640 KB | Output is correct |
30 | Correct | 2 ms | 640 KB | Output is correct |
31 | Correct | 2 ms | 640 KB | Output is correct |
32 | Correct | 2 ms | 640 KB | Output is correct |
33 | Correct | 2 ms | 752 KB | Output is correct |
34 | Correct | 2 ms | 752 KB | Output is correct |
35 | Correct | 2 ms | 752 KB | Output is correct |
36 | Correct | 2 ms | 752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 752 KB | Output is correct |
2 | Correct | 2 ms | 752 KB | Output is correct |
3 | Correct | 2 ms | 752 KB | Output is correct |
4 | Correct | 2 ms | 752 KB | Output is correct |
5 | Correct | 2 ms | 752 KB | Output is correct |
6 | Correct | 2 ms | 752 KB | Output is correct |
7 | Correct | 2 ms | 752 KB | Output is correct |
8 | Correct | 2 ms | 752 KB | Output is correct |
9 | Correct | 2 ms | 752 KB | Output is correct |
10 | Correct | 2 ms | 752 KB | Output is correct |
11 | Correct | 2 ms | 752 KB | Output is correct |
12 | Correct | 2 ms | 752 KB | Output is correct |
13 | Correct | 2 ms | 752 KB | Output is correct |
14 | Correct | 2 ms | 752 KB | Output is correct |
15 | Correct | 2 ms | 752 KB | Output is correct |
16 | Correct | 2 ms | 752 KB | Output is correct |
17 | Correct | 2 ms | 752 KB | Output is correct |
18 | Correct | 2 ms | 752 KB | Output is correct |
19 | Correct | 2 ms | 752 KB | Output is correct |
20 | Correct | 2 ms | 752 KB | Output is correct |
21 | Correct | 2 ms | 752 KB | Output is correct |
22 | Correct | 2 ms | 752 KB | Output is correct |
23 | Correct | 2 ms | 752 KB | Output is correct |
24 | Correct | 2 ms | 752 KB | Output is correct |
25 | Correct | 2 ms | 752 KB | Output is correct |
26 | Correct | 2 ms | 752 KB | Output is correct |
27 | Correct | 2 ms | 752 KB | Output is correct |
28 | Correct | 2 ms | 752 KB | Output is correct |
29 | Correct | 2 ms | 752 KB | Output is correct |
30 | Correct | 2 ms | 752 KB | Output is correct |
31 | Correct | 2 ms | 752 KB | Output is correct |
32 | Correct | 2 ms | 752 KB | Output is correct |
33 | Correct | 2 ms | 752 KB | Output is correct |
34 | Correct | 2 ms | 752 KB | Output is correct |
35 | Correct | 2 ms | 752 KB | Output is correct |
36 | Correct | 3 ms | 752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 752 KB | Output is correct |
2 | Correct | 2 ms | 752 KB | Output is correct |
3 | Correct | 2 ms | 752 KB | Output is correct |
4 | Correct | 2 ms | 752 KB | Output is correct |
5 | Correct | 2 ms | 752 KB | Output is correct |
6 | Correct | 2 ms | 752 KB | Output is correct |
7 | Correct | 2 ms | 752 KB | Output is correct |
8 | Correct | 2 ms | 752 KB | Output is correct |
9 | Correct | 2 ms | 752 KB | Output is correct |
10 | Correct | 2 ms | 752 KB | Output is correct |
11 | Correct | 2 ms | 752 KB | Output is correct |
12 | Correct | 2 ms | 752 KB | Output is correct |
13 | Correct | 2 ms | 756 KB | Output is correct |
14 | Correct | 2 ms | 756 KB | Output is correct |
15 | Correct | 2 ms | 756 KB | Output is correct |
16 | Correct | 2 ms | 756 KB | Output is correct |
17 | Correct | 2 ms | 756 KB | Output is correct |
18 | Correct | 2 ms | 756 KB | Output is correct |
19 | Correct | 2 ms | 756 KB | Output is correct |
20 | Correct | 3 ms | 756 KB | Output is correct |
21 | Correct | 2 ms | 756 KB | Output is correct |
22 | Correct | 3 ms | 756 KB | Output is correct |
23 | Correct | 2 ms | 756 KB | Output is correct |
24 | Correct | 2 ms | 756 KB | Output is correct |
25 | Correct | 2 ms | 756 KB | Output is correct |
26 | Correct | 3 ms | 756 KB | Output is correct |
27 | Correct | 3 ms | 756 KB | Output is correct |
28 | Correct | 3 ms | 756 KB | Output is correct |
29 | Correct | 3 ms | 756 KB | Output is correct |
30 | Correct | 4 ms | 756 KB | Output is correct |
31 | Correct | 4 ms | 756 KB | Output is correct |
32 | Correct | 3 ms | 756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 756 KB | Output is correct |
2 | Correct | 2 ms | 756 KB | Output is correct |
3 | Correct | 2 ms | 756 KB | Output is correct |
4 | Correct | 2 ms | 756 KB | Output is correct |
5 | Correct | 2 ms | 756 KB | Output is correct |
6 | Correct | 2 ms | 756 KB | Output is correct |
7 | Correct | 2 ms | 756 KB | Output is correct |
8 | Correct | 2 ms | 756 KB | Output is correct |
9 | Correct | 2 ms | 756 KB | Output is correct |
10 | Correct | 2 ms | 756 KB | Output is correct |
11 | Correct | 2 ms | 756 KB | Output is correct |
12 | Correct | 2 ms | 756 KB | Output is correct |
13 | Correct | 2 ms | 756 KB | Output is correct |
14 | Correct | 2 ms | 756 KB | Output is correct |
15 | Correct | 2 ms | 756 KB | Output is correct |
16 | Correct | 2 ms | 756 KB | Output is correct |
17 | Correct | 2 ms | 756 KB | Output is correct |
18 | Correct | 2 ms | 756 KB | Output is correct |
19 | Correct | 2 ms | 756 KB | Output is correct |
20 | Correct | 2 ms | 756 KB | Output is correct |
21 | Correct | 2 ms | 756 KB | Output is correct |
22 | Correct | 2 ms | 756 KB | Output is correct |
23 | Correct | 2 ms | 756 KB | Output is correct |
24 | Correct | 2 ms | 756 KB | Output is correct |
25 | Correct | 2 ms | 756 KB | Output is correct |
26 | Correct | 2 ms | 756 KB | Output is correct |
27 | Correct | 2 ms | 756 KB | Output is correct |
28 | Correct | 2 ms | 756 KB | Output is correct |
29 | Correct | 2 ms | 756 KB | Output is correct |
30 | Correct | 2 ms | 756 KB | Output is correct |
31 | Correct | 2 ms | 756 KB | Output is correct |
32 | Correct | 2 ms | 756 KB | Output is correct |
33 | Correct | 2 ms | 756 KB | Output is correct |
34 | Correct | 2 ms | 756 KB | Output is correct |
35 | Correct | 2 ms | 756 KB | Output is correct |
36 | Correct | 2 ms | 756 KB | Output is correct |
37 | Correct | 2 ms | 756 KB | Output is correct |
38 | Correct | 2 ms | 756 KB | Output is correct |
39 | Correct | 2 ms | 756 KB | Output is correct |
40 | Correct | 2 ms | 756 KB | Output is correct |
41 | Correct | 2 ms | 756 KB | Output is correct |
42 | Correct | 2 ms | 756 KB | Output is correct |
43 | Correct | 2 ms | 756 KB | Output is correct |
44 | Correct | 2 ms | 756 KB | Output is correct |
45 | Correct | 2 ms | 756 KB | Output is correct |
46 | Correct | 2 ms | 756 KB | Output is correct |
47 | Correct | 2 ms | 756 KB | Output is correct |
48 | Correct | 2 ms | 756 KB | Output is correct |
49 | Correct | 2 ms | 756 KB | Output is correct |
50 | Correct | 3 ms | 756 KB | Output is correct |
51 | Correct | 3 ms | 756 KB | Output is correct |
52 | Correct | 3 ms | 756 KB | Output is correct |
53 | Correct | 3 ms | 756 KB | Output is correct |
54 | Correct | 3 ms | 756 KB | Output is correct |
55 | Correct | 3 ms | 756 KB | Output is correct |
56 | Correct | 2 ms | 756 KB | Output is correct |
57 | Correct | 3 ms | 756 KB | Output is correct |
58 | Correct | 3 ms | 756 KB | Output is correct |
59 | Correct | 3 ms | 756 KB | Output is correct |
60 | Correct | 3 ms | 756 KB | Output is correct |
61 | Correct | 4 ms | 756 KB | Output is correct |
62 | Correct | 4 ms | 756 KB | Output is correct |
63 | Correct | 4 ms | 756 KB | Output is correct |
64 | Correct | 2 ms | 756 KB | Output is correct |
65 | Correct | 2 ms | 756 KB | Output is correct |
66 | Correct | 3 ms | 756 KB | Output is correct |
67 | Correct | 4 ms | 756 KB | Output is correct |
68 | Correct | 3 ms | 764 KB | Output is correct |
69 | Correct | 3 ms | 764 KB | Output is correct |
70 | Correct | 3 ms | 764 KB | Output is correct |
71 | Correct | 4 ms | 764 KB | Output is correct |
72 | Correct | 4 ms | 764 KB | Output is correct |
73 | Correct | 4 ms | 764 KB | Output is correct |
74 | Correct | 4 ms | 764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 764 KB | Output is correct |
2 | Correct | 2 ms | 764 KB | Output is correct |
3 | Correct | 2 ms | 764 KB | Output is correct |
4 | Correct | 2 ms | 764 KB | Output is correct |
5 | Correct | 2 ms | 764 KB | Output is correct |
6 | Correct | 2 ms | 764 KB | Output is correct |
7 | Correct | 2 ms | 764 KB | Output is correct |
8 | Correct | 2 ms | 764 KB | Output is correct |
9 | Correct | 2 ms | 764 KB | Output is correct |
10 | Correct | 2 ms | 764 KB | Output is correct |
11 | Correct | 2 ms | 764 KB | Output is correct |
12 | Correct | 2 ms | 764 KB | Output is correct |
13 | Correct | 2 ms | 764 KB | Output is correct |
14 | Correct | 2 ms | 764 KB | Output is correct |
15 | Correct | 2 ms | 764 KB | Output is correct |
16 | Correct | 2 ms | 764 KB | Output is correct |
17 | Correct | 2 ms | 764 KB | Output is correct |
18 | Correct | 2 ms | 764 KB | Output is correct |
19 | Correct | 2 ms | 764 KB | Output is correct |
20 | Correct | 2 ms | 764 KB | Output is correct |
21 | Correct | 2 ms | 764 KB | Output is correct |
22 | Correct | 2 ms | 764 KB | Output is correct |
23 | Correct | 2 ms | 764 KB | Output is correct |
24 | Correct | 2 ms | 764 KB | Output is correct |
25 | Correct | 2 ms | 764 KB | Output is correct |
26 | Correct | 2 ms | 764 KB | Output is correct |
27 | Correct | 2 ms | 764 KB | Output is correct |
28 | Correct | 2 ms | 764 KB | Output is correct |
29 | Correct | 2 ms | 764 KB | Output is correct |
30 | Correct | 2 ms | 764 KB | Output is correct |
31 | Correct | 2 ms | 764 KB | Output is correct |
32 | Correct | 2 ms | 764 KB | Output is correct |
33 | Correct | 2 ms | 764 KB | Output is correct |
34 | Correct | 3 ms | 764 KB | Output is correct |
35 | Correct | 2 ms | 764 KB | Output is correct |
36 | Correct | 2 ms | 764 KB | Output is correct |
37 | Correct | 3 ms | 764 KB | Output is correct |
38 | Correct | 3 ms | 764 KB | Output is correct |
39 | Correct | 3 ms | 764 KB | Output is correct |
40 | Correct | 4 ms | 764 KB | Output is correct |
41 | Correct | 3 ms | 764 KB | Output is correct |
42 | Correct | 3 ms | 764 KB | Output is correct |
43 | Correct | 2 ms | 764 KB | Output is correct |
44 | Correct | 3 ms | 764 KB | Output is correct |
45 | Correct | 3 ms | 764 KB | Output is correct |
46 | Correct | 3 ms | 764 KB | Output is correct |
47 | Correct | 3 ms | 764 KB | Output is correct |
48 | Correct | 5 ms | 764 KB | Output is correct |
49 | Correct | 4 ms | 764 KB | Output is correct |
50 | Correct | 3 ms | 764 KB | Output is correct |
51 | Correct | 3 ms | 764 KB | Output is correct |
52 | Correct | 45 ms | 764 KB | Output is correct |
53 | Correct | 60 ms | 764 KB | Output is correct |
54 | Correct | 107 ms | 892 KB | Output is correct |
55 | Correct | 97 ms | 892 KB | Output is correct |
56 | Correct | 357 ms | 1020 KB | Output is correct |
57 | Correct | 341 ms | 1148 KB | Output is correct |
58 | Correct | 348 ms | 1148 KB | Output is correct |
59 | Correct | 357 ms | 1148 KB | Output is correct |
60 | Correct | 572 ms | 1148 KB | Output is correct |
61 | Correct | 6 ms | 1148 KB | Output is correct |
62 | Correct | 102 ms | 1148 KB | Output is correct |
63 | Correct | 150 ms | 1148 KB | Output is correct |
64 | Correct | 122 ms | 1148 KB | Output is correct |
65 | Correct | 185 ms | 1148 KB | Output is correct |
66 | Correct | 378 ms | 1148 KB | Output is correct |
67 | Correct | 492 ms | 1148 KB | Output is correct |
68 | Correct | 470 ms | 1156 KB | Output is correct |
69 | Correct | 419 ms | 1160 KB | Output is correct |