Submission #597250

# Submission time Handle Problem Language Result Execution time Memory
597250 2022-07-15T19:39:28 Z Belphegor Bali Sculptures (APIO15_sculpture) C++14
25 / 100
268 ms 3912 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[55][22][1005];
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<=1000; 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<=1000; 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

sculpture.cpp: In function 'll subtask1()':
sculpture.cpp:12:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |   if(v.size()<a || v.size()>b) continue;
      |      ~~~~~~~~^~
sculpture.cpp:12:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |   if(v.size()<a || v.size()>b) continue;
      |                    ~~~~~~~~^~
sculpture.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int j=1; j<v.size(); j++){
      |                ~^~~~~~~~~
# 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 332 KB Output is correct
7 Correct 24 ms 212 KB Output is correct
8 Correct 198 ms 332 KB Output is correct
9 Correct 204 ms 332 KB Output is correct
10 Correct 201 ms 308 KB Output is correct
11 Correct 206 ms 212 KB Output is correct
12 Correct 197 ms 308 KB Output is correct
13 Correct 256 ms 308 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 336 KB Output is correct
20 Correct 24 ms 304 KB Output is correct
21 Correct 202 ms 312 KB Output is correct
22 Correct 217 ms 312 KB Output is correct
23 Correct 214 ms 304 KB Output is correct
24 Correct 216 ms 308 KB Output is correct
25 Correct 213 ms 304 KB Output is correct
26 Correct 231 ms 212 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 103 ms 316 KB Output is correct
31 Correct 206 ms 304 KB Output is correct
32 Correct 199 ms 212 KB Output is correct
33 Correct 258 ms 312 KB Output is correct
34 Correct 229 ms 304 KB Output is correct
35 Correct 206 ms 308 KB Output is correct
36 Correct 258 ms 304 KB Output is correct
# 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 296 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 26 ms 212 KB Output is correct
8 Correct 208 ms 304 KB Output is correct
9 Correct 198 ms 212 KB Output is correct
10 Correct 223 ms 308 KB Output is correct
11 Correct 211 ms 212 KB Output is correct
12 Correct 196 ms 312 KB Output is correct
13 Correct 236 ms 308 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 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 0 ms 212 KB Output is correct
19 Correct 6 ms 332 KB Output is correct
20 Correct 24 ms 212 KB Output is correct
21 Correct 199 ms 308 KB Output is correct
22 Correct 200 ms 308 KB Output is correct
23 Correct 204 ms 312 KB Output is correct
24 Correct 268 ms 212 KB Output is correct
25 Correct 208 ms 308 KB Output is correct
26 Correct 228 ms 212 KB Output is correct
27 Correct 2 ms 1236 KB Output is correct
28 Correct 1 ms 1492 KB Output is correct
29 Correct 4 ms 2756 KB Output is correct
30 Correct 4 ms 3028 KB Output is correct
31 Correct 7 ms 3796 KB Output is correct
32 Correct 5 ms 3796 KB Output is correct
33 Correct 5 ms 3796 KB Output is correct
34 Correct 6 ms 3796 KB Output is correct
35 Correct 6 ms 3796 KB Output is correct
36 Correct 7 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 9 ms 324 KB Output is correct
7 Correct 25 ms 328 KB Output is correct
8 Correct 217 ms 308 KB Output is correct
9 Correct 201 ms 320 KB Output is correct
10 Correct 204 ms 312 KB Output is correct
11 Correct 197 ms 212 KB Output is correct
12 Correct 204 ms 312 KB Output is correct
13 Correct 227 ms 320 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1492 KB Output is correct
16 Correct 3 ms 2768 KB Output is correct
17 Correct 4 ms 3028 KB Output is correct
18 Correct 7 ms 3796 KB Output is correct
19 Correct 5 ms 3740 KB Output is correct
20 Correct 5 ms 3788 KB Output is correct
21 Correct 6 ms 3796 KB Output is correct
22 Correct 6 ms 3796 KB Output is correct
23 Correct 7 ms 3784 KB Output is correct
24 Correct 8 ms 3912 KB Output is correct
25 Runtime error 2 ms 852 KB Execution killed with signal 11
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 212 KB Output is correct
7 Correct 25 ms 332 KB Output is correct
8 Correct 200 ms 212 KB Output is correct
9 Correct 212 ms 320 KB Output is correct
10 Correct 194 ms 304 KB Output is correct
11 Correct 202 ms 304 KB Output is correct
12 Correct 211 ms 308 KB Output is correct
13 Correct 224 ms 312 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 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 0 ms 212 KB Output is correct
19 Correct 7 ms 212 KB Output is correct
20 Correct 31 ms 256 KB Output is correct
21 Correct 226 ms 212 KB Output is correct
22 Correct 208 ms 304 KB Output is correct
23 Correct 231 ms 308 KB Output is correct
24 Correct 197 ms 332 KB Output is correct
25 Correct 208 ms 308 KB Output is correct
26 Correct 235 ms 212 KB Output is correct
27 Correct 1 ms 292 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 3 ms 332 KB Output is correct
30 Correct 97 ms 212 KB Output is correct
31 Correct 205 ms 312 KB Output is correct
32 Correct 238 ms 320 KB Output is correct
33 Correct 227 ms 304 KB Output is correct
34 Correct 240 ms 312 KB Output is correct
35 Correct 199 ms 212 KB Output is correct
36 Correct 229 ms 308 KB Output is correct
37 Correct 2 ms 1236 KB Output is correct
38 Correct 1 ms 1492 KB Output is correct
39 Correct 4 ms 2768 KB Output is correct
40 Correct 4 ms 3028 KB Output is correct
41 Correct 8 ms 3796 KB Output is correct
42 Correct 5 ms 3796 KB Output is correct
43 Correct 5 ms 3796 KB Output is correct
44 Correct 6 ms 3796 KB Output is correct
45 Correct 6 ms 3796 KB Output is correct
46 Correct 7 ms 3796 KB Output is correct
47 Correct 8 ms 3884 KB Output is correct
48 Runtime error 1 ms 848 KB Execution killed with signal 11
49 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 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 328 KB Output is correct
7 Correct 29 ms 328 KB Output is correct
8 Correct 211 ms 212 KB Output is correct
9 Correct 203 ms 308 KB Output is correct
10 Correct 206 ms 312 KB Output is correct
11 Correct 204 ms 312 KB Output is correct
12 Correct 212 ms 304 KB Output is correct
13 Correct 240 ms 320 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 324 KB Output is correct
17 Correct 100 ms 328 KB Output is correct
18 Correct 226 ms 324 KB Output is correct
19 Correct 213 ms 304 KB Output is correct
20 Correct 251 ms 308 KB Output is correct
21 Correct 239 ms 304 KB Output is correct
22 Correct 203 ms 312 KB Output is correct
23 Correct 232 ms 312 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1492 KB Output is correct
26 Correct 3 ms 2764 KB Output is correct
27 Correct 4 ms 3028 KB Output is correct
28 Correct 8 ms 3796 KB Output is correct
29 Correct 5 ms 3796 KB Output is correct
30 Correct 6 ms 3788 KB Output is correct
31 Correct 7 ms 3796 KB Output is correct
32 Correct 6 ms 3796 KB Output is correct
33 Correct 7 ms 3796 KB Output is correct
34 Correct 8 ms 3856 KB Output is correct
35 Runtime error 2 ms 852 KB Execution killed with signal 11
36 Halted 0 ms 0 KB -