# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
597251 | 2022-07-15T19:40:41 Z | Belphegor | Bali Sculptures (APIO15_sculpture) | C++14 | 262 ms | 31052 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n,a,b; ll arr[105]; ll subtask1(){ ll ans = INT64_MAX; for(int i=1; i<(1<<n); i++){ vector<int>v; for(int j=0; j<n; j++) if(i&(1<<j)) v.emplace_back(j); if(v.back()!=n-1) continue; if(v.size()<a || v.size()>b) continue; ll ret = 0; for(int j=0; j<=v[0]; j++) ret+=arr[j]; for(int j=1; j<v.size(); j++){ ll sum = 0; for(int k=v[j-1]+1; k<=v[j]; k++) sum+=arr[k]; ret|=sum; } ans = min(ans,ret); } return ans; } int dp[105][105][2005]; int subtask2(){ for(int i=n; i>=1; i--) arr[i] = arr[i-1]; arr[0] = 0; for(int i=1; i<=n; i++) arr[i]+=arr[i-1]; dp[0][0][0] = 1; int ret = arr[n]; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ for(int val = 0; val<=arr[n]; val++){ if(!dp[j][i][val]) continue; for(int k=j+1; k<=n; k++){ int v = val | (arr[k]-arr[j]); dp[k][i+1][v] = 1; } } } if(a<=i && i<=b){ for(int j=0; j<=arr[n]; j++){ if(dp[n][i][j]) ret = min(ret,j); } } } return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>a>>b; for(int i=0; i<n; i++) cin>>arr[i]; if(n<=20) cout<<subtask1(); else cout<<subtask2(); }
Compilation message
# | 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 | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 212 KB | Output is correct |
7 | Correct | 30 ms | 212 KB | Output is correct |
8 | Correct | 219 ms | 304 KB | Output is correct |
9 | Correct | 206 ms | 312 KB | Output is correct |
10 | Correct | 205 ms | 212 KB | Output is correct |
11 | Correct | 203 ms | 308 KB | Output is correct |
12 | Correct | 209 ms | 304 KB | Output is correct |
13 | Correct | 239 ms | 304 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 6 ms | 212 KB | Output is correct |
20 | Correct | 26 ms | 304 KB | Output is correct |
21 | Correct | 212 ms | 212 KB | Output is correct |
22 | Correct | 212 ms | 212 KB | Output is correct |
23 | Correct | 211 ms | 312 KB | Output is correct |
24 | Correct | 203 ms | 316 KB | Output is correct |
25 | Correct | 211 ms | 212 KB | Output is correct |
26 | Correct | 228 ms | 300 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 2 ms | 212 KB | Output is correct |
30 | Correct | 107 ms | 304 KB | Output is correct |
31 | Correct | 218 ms | 304 KB | Output is correct |
32 | Correct | 200 ms | 212 KB | Output is correct |
33 | Correct | 245 ms | 308 KB | Output is correct |
34 | Correct | 233 ms | 312 KB | Output is correct |
35 | Correct | 204 ms | 304 KB | Output is correct |
36 | Correct | 251 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 | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 212 KB | Output is correct |
7 | Correct | 24 ms | 212 KB | Output is correct |
8 | Correct | 215 ms | 212 KB | Output is correct |
9 | Correct | 211 ms | 300 KB | Output is correct |
10 | Correct | 204 ms | 304 KB | Output is correct |
11 | Correct | 207 ms | 308 KB | Output is correct |
12 | Correct | 229 ms | 312 KB | Output is correct |
13 | Correct | 230 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 6 ms | 324 KB | Output is correct |
20 | Correct | 31 ms | 308 KB | Output is correct |
21 | Correct | 214 ms | 316 KB | Output is correct |
22 | Correct | 206 ms | 300 KB | Output is correct |
23 | Correct | 209 ms | 212 KB | Output is correct |
24 | Correct | 225 ms | 300 KB | Output is correct |
25 | Correct | 203 ms | 300 KB | Output is correct |
26 | Correct | 238 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 1236 KB | Output is correct |
28 | Correct | 1 ms | 1620 KB | Output is correct |
29 | Correct | 2 ms | 3412 KB | Output is correct |
30 | Correct | 3 ms | 4180 KB | Output is correct |
31 | Correct | 6 ms | 6144 KB | Output is correct |
32 | Correct | 5 ms | 6100 KB | Output is correct |
33 | Correct | 5 ms | 6100 KB | Output is correct |
34 | Correct | 4 ms | 5844 KB | Output is correct |
35 | Correct | 5 ms | 5844 KB | Output is correct |
36 | Correct | 5 ms | 5844 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 | 7 ms | 212 KB | Output is correct |
7 | Correct | 26 ms | 212 KB | Output is correct |
8 | Correct | 207 ms | 300 KB | Output is correct |
9 | Correct | 214 ms | 304 KB | Output is correct |
10 | Correct | 210 ms | 332 KB | Output is correct |
11 | Correct | 209 ms | 300 KB | Output is correct |
12 | Correct | 214 ms | 304 KB | Output is correct |
13 | Correct | 232 ms | 308 KB | Output is correct |
14 | Correct | 1 ms | 1236 KB | Output is correct |
15 | Correct | 1 ms | 1620 KB | Output is correct |
16 | Correct | 2 ms | 3412 KB | Output is correct |
17 | Correct | 3 ms | 4188 KB | Output is correct |
18 | Correct | 6 ms | 6100 KB | Output is correct |
19 | Correct | 5 ms | 6100 KB | Output is correct |
20 | Correct | 5 ms | 6100 KB | Output is correct |
21 | Correct | 6 ms | 5844 KB | Output is correct |
22 | Correct | 5 ms | 5844 KB | Output is correct |
23 | Correct | 5 ms | 5844 KB | Output is correct |
24 | Correct | 7 ms | 6528 KB | Output is correct |
25 | Correct | 13 ms | 10716 KB | Output is correct |
26 | Correct | 20 ms | 15956 KB | Output is correct |
27 | Correct | 33 ms | 22220 KB | Output is correct |
28 | Correct | 41 ms | 27004 KB | Output is correct |
29 | Incorrect | 39 ms | 31040 KB | Output isn't correct |
30 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 11 ms | 324 KB | Output is correct |
7 | Correct | 28 ms | 212 KB | Output is correct |
8 | Correct | 210 ms | 308 KB | Output is correct |
9 | Correct | 201 ms | 212 KB | Output is correct |
10 | Correct | 209 ms | 300 KB | Output is correct |
11 | Correct | 217 ms | 316 KB | Output is correct |
12 | Correct | 201 ms | 212 KB | Output is correct |
13 | Correct | 234 ms | 296 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 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 | 7 ms | 328 KB | Output is correct |
20 | Correct | 24 ms | 324 KB | Output is correct |
21 | Correct | 203 ms | 212 KB | Output is correct |
22 | Correct | 227 ms | 300 KB | Output is correct |
23 | Correct | 241 ms | 332 KB | Output is correct |
24 | Correct | 211 ms | 308 KB | Output is correct |
25 | Correct | 245 ms | 212 KB | Output is correct |
26 | Correct | 231 ms | 308 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 2 ms | 212 KB | Output is correct |
30 | Correct | 103 ms | 304 KB | Output is correct |
31 | Correct | 223 ms | 308 KB | Output is correct |
32 | Correct | 203 ms | 308 KB | Output is correct |
33 | Correct | 228 ms | 300 KB | Output is correct |
34 | Correct | 262 ms | 300 KB | Output is correct |
35 | Correct | 207 ms | 304 KB | Output is correct |
36 | Correct | 231 ms | 304 KB | Output is correct |
37 | Correct | 1 ms | 1236 KB | Output is correct |
38 | Correct | 2 ms | 1620 KB | Output is correct |
39 | Correct | 2 ms | 3412 KB | Output is correct |
40 | Correct | 3 ms | 4180 KB | Output is correct |
41 | Correct | 7 ms | 6100 KB | Output is correct |
42 | Correct | 5 ms | 6100 KB | Output is correct |
43 | Correct | 6 ms | 6100 KB | Output is correct |
44 | Correct | 5 ms | 5844 KB | Output is correct |
45 | Correct | 4 ms | 5844 KB | Output is correct |
46 | Correct | 5 ms | 5844 KB | Output is correct |
47 | Correct | 6 ms | 6484 KB | Output is correct |
48 | Correct | 13 ms | 10724 KB | Output is correct |
49 | Correct | 21 ms | 15952 KB | Output is correct |
50 | Correct | 32 ms | 22248 KB | Output is correct |
51 | Correct | 42 ms | 27008 KB | Output is correct |
52 | Incorrect | 48 ms | 31052 KB | Output isn't correct |
53 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | 7 ms | 320 KB | Output is correct |
7 | Correct | 24 ms | 324 KB | Output is correct |
8 | Correct | 201 ms | 300 KB | Output is correct |
9 | Correct | 200 ms | 304 KB | Output is correct |
10 | Correct | 213 ms | 304 KB | Output is correct |
11 | Correct | 199 ms | 304 KB | Output is correct |
12 | Correct | 200 ms | 212 KB | Output is correct |
13 | Correct | 247 ms | 304 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 2 ms | 288 KB | Output is correct |
17 | Correct | 98 ms | 212 KB | Output is correct |
18 | Correct | 208 ms | 300 KB | Output is correct |
19 | Correct | 212 ms | 300 KB | Output is correct |
20 | Correct | 231 ms | 304 KB | Output is correct |
21 | Correct | 246 ms | 212 KB | Output is correct |
22 | Correct | 214 ms | 332 KB | Output is correct |
23 | Correct | 237 ms | 300 KB | Output is correct |
24 | Correct | 1 ms | 1236 KB | Output is correct |
25 | Correct | 2 ms | 1620 KB | Output is correct |
26 | Correct | 3 ms | 3464 KB | Output is correct |
27 | Correct | 3 ms | 4180 KB | Output is correct |
28 | Correct | 7 ms | 6100 KB | Output is correct |
29 | Correct | 7 ms | 6100 KB | Output is correct |
30 | Correct | 5 ms | 6100 KB | Output is correct |
31 | Correct | 5 ms | 5844 KB | Output is correct |
32 | Correct | 4 ms | 5844 KB | Output is correct |
33 | Correct | 5 ms | 5844 KB | Output is correct |
34 | Correct | 7 ms | 6524 KB | Output is correct |
35 | Correct | 13 ms | 10708 KB | Output is correct |
36 | Correct | 20 ms | 15972 KB | Output is correct |
37 | Correct | 31 ms | 22236 KB | Output is correct |
38 | Correct | 43 ms | 26988 KB | Output is correct |
39 | Incorrect | 41 ms | 31052 KB | Output isn't correct |
40 | Halted | 0 ms | 0 KB | - |