# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
978709 | 2024-05-09T14:18:36 Z | SmuggingSpun | Bali Sculptures (APIO15_sculpture) | C++14 | 40 ms | 756 KB |
#include<bits/stdc++.h> #define taskname "sculpture" using namespace std; typedef long long ll; template<class T>void minimize(T& a, T b){ if(a > b){ a = b; } } int n, a, b; vector<int>y; namespace sub1{ void solve(){ ll ans = LLONG_MAX; for(int mask = (1 << n) - 2; mask > -1; mask -= 2){ int cnt_1 = __builtin_popcount(mask) + 1; if(a <= cnt_1 && cnt_1 <= b){ ll value = 0, sum = 0; for(int i = 0; i < n; ){ if(1 << i & mask){ value |= sum; sum = 0; } sum += y[++i]; } minimize(ans, value | sum); } } cout << ans; } } namespace sub23{ void solve(){ } } namespace sub45{ void solve(){ } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n >> a >> b; y.resize(n + 1); for(int i = 1; i <= n; i++){ cin >> y[i]; } if(n <= 20){ sub1::solve(); } else if(n <= 100 && *max_element(y.begin() + 1, y.end()) <= 20){ sub23::solve(); } else{ sub45::solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 404 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 344 KB | Output is correct |
9 | Correct | 2 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 372 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 452 KB | Output is correct |
13 | Correct | 35 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 600 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 4 ms | 456 KB | Output is correct |
22 | Correct | 4 ms | 348 KB | Output is correct |
23 | Correct | 4 ms | 348 KB | Output is correct |
24 | Correct | 2 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 32 ms | 452 KB | Output is correct |
27 | Correct | 1 ms | 756 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 5 ms | 452 KB | Output is correct |
32 | Correct | 2 ms | 348 KB | Output is correct |
33 | Correct | 31 ms | 348 KB | Output is correct |
34 | Correct | 36 ms | 348 KB | Output is correct |
35 | Correct | 2 ms | 348 KB | Output is correct |
36 | Correct | 35 ms | 432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 344 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 34 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 4 ms | 452 KB | Output is correct |
22 | Correct | 4 ms | 348 KB | Output is correct |
23 | Correct | 4 ms | 348 KB | Output is correct |
24 | Correct | 2 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 31 ms | 348 KB | Output is correct |
27 | Incorrect | 1 ms | 348 KB | Output isn't correct |
28 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 456 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 456 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 35 ms | 344 KB | Output is correct |
14 | Incorrect | 0 ms | 348 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 456 KB | Output is correct |
12 | Correct | 2 ms | 348 KB | Output is correct |
13 | Correct | 34 ms | 452 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 4 ms | 348 KB | Output is correct |
22 | Correct | 4 ms | 348 KB | Output is correct |
23 | Correct | 4 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 32 ms | 344 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 4 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 34 ms | 596 KB | Output is correct |
34 | Correct | 35 ms | 348 KB | Output is correct |
35 | Correct | 2 ms | 344 KB | Output is correct |
36 | Correct | 37 ms | 348 KB | Output is correct |
37 | Incorrect | 0 ms | 348 KB | Output isn't correct |
38 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 2 ms | 460 KB | Output is correct |
13 | Correct | 35 ms | 456 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 452 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 4 ms | 452 KB | Output is correct |
19 | Correct | 2 ms | 344 KB | Output is correct |
20 | Correct | 33 ms | 696 KB | Output is correct |
21 | Correct | 40 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 35 ms | 452 KB | Output is correct |
24 | Incorrect | 0 ms | 348 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |