# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164746 | 2019-11-23T06:51:10 Z | quocnguyen1012 | Bali Sculptures (APIO15_sculpture) | C++14 | 328 ms | 504 KB |
#include <bits/stdc++.h> #define Task "or" #define pb push_back #define int long long using namespace std; typedef long long ll; mt19937 rng (chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 2005; int testbit (ll x, int n){ return x >> n & 1; } int N; int a[maxn]; ll sum[maxn]; ll f[maxn]; int P, Q; bool submask (ll mask1, ll mask2){ return (mask1 & mask2) == mask1; } bool check (ll mask){ for (int i=1; i<=N; ++i) f[i] = 1e9; for (int i=1; i<=N; ++i){ for (int j=i-1; j>=0; --j){ if (f[j] < 1e9 && submask (sum[i] - sum[j], mask)){ f[i] = min(f[i], f[j] + 1); } } } //cerr << f[N]; return f[N] <= Q; } signed main (void){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen (Task".in", "r")){ freopen (Task".in", "r", stdin); freopen (Task".out", "w", stdout); } cin >> N >> P >> Q; for (int i=1; i<=N; ++i){ cin >> a[i]; sum[i] = sum[i-1] + a[i]; } ll ans = (1ll << 62) - 1; for (int i=61; i>=0; --i){ if (check (ans -(1ll << i))) ans -= (1ll << i); ///cerr << ans << '\n'; } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 276 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 380 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Incorrect | 2 ms | 376 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 372 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
12 | Correct | 2 ms | 380 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 7 ms | 376 KB | Output is correct |
15 | Incorrect | 2 ms | 376 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 372 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 380 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 3 ms | 376 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 376 KB | Output is correct |
28 | Correct | 3 ms | 380 KB | Output is correct |
29 | Correct | 3 ms | 376 KB | Output is correct |
30 | Correct | 3 ms | 376 KB | Output is correct |
31 | Correct | 3 ms | 376 KB | Output is correct |
32 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
12 | Correct | 2 ms | 504 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Incorrect | 2 ms | 376 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 380 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 380 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 2 ms | 376 KB | Output is correct |
35 | Correct | 3 ms | 376 KB | Output is correct |
36 | Correct | 3 ms | 376 KB | Output is correct |
37 | Correct | 3 ms | 376 KB | Output is correct |
38 | Correct | 3 ms | 376 KB | Output is correct |
39 | Correct | 3 ms | 396 KB | Output is correct |
40 | Correct | 3 ms | 376 KB | Output is correct |
41 | Correct | 3 ms | 376 KB | Output is correct |
42 | Correct | 3 ms | 376 KB | Output is correct |
43 | Correct | 3 ms | 376 KB | Output is correct |
44 | Correct | 3 ms | 376 KB | Output is correct |
45 | Correct | 3 ms | 376 KB | Output is correct |
46 | Correct | 3 ms | 380 KB | Output is correct |
47 | Correct | 3 ms | 376 KB | Output is correct |
48 | Correct | 3 ms | 376 KB | Output is correct |
49 | Correct | 3 ms | 376 KB | Output is correct |
50 | Correct | 3 ms | 376 KB | Output is correct |
51 | Correct | 3 ms | 380 KB | Output is correct |
52 | Correct | 31 ms | 376 KB | Output is correct |
53 | Correct | 38 ms | 376 KB | Output is correct |
54 | Correct | 82 ms | 504 KB | Output is correct |
55 | Correct | 99 ms | 376 KB | Output is correct |
56 | Correct | 251 ms | 504 KB | Output is correct |
57 | Correct | 247 ms | 376 KB | Output is correct |
58 | Correct | 247 ms | 376 KB | Output is correct |
59 | Correct | 255 ms | 376 KB | Output is correct |
60 | Correct | 265 ms | 376 KB | Output is correct |
61 | Correct | 3 ms | 376 KB | Output is correct |
62 | Correct | 39 ms | 380 KB | Output is correct |
63 | Correct | 79 ms | 376 KB | Output is correct |
64 | Correct | 65 ms | 376 KB | Output is correct |
65 | Correct | 122 ms | 376 KB | Output is correct |
66 | Correct | 199 ms | 380 KB | Output is correct |
67 | Correct | 245 ms | 500 KB | Output is correct |
68 | Correct | 294 ms | 376 KB | Output is correct |
69 | Correct | 328 ms | 380 KB | Output is correct |