답안 #597252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597252 2022-07-15T19:42:06 Z Belphegor Bali Sculptures (APIO15_sculpture) C++14
25 / 100
267 ms 31180 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<=2000; 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<=2000; 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++){
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 7 ms 212 KB Output is correct
7 Correct 24 ms 212 KB Output is correct
8 Correct 210 ms 308 KB Output is correct
9 Correct 224 ms 212 KB Output is correct
10 Correct 201 ms 304 KB Output is correct
11 Correct 207 ms 300 KB Output is correct
12 Correct 209 ms 212 KB Output is correct
13 Correct 236 ms 312 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 25 ms 212 KB Output is correct
21 Correct 204 ms 304 KB Output is correct
22 Correct 201 ms 212 KB Output is correct
23 Correct 211 ms 308 KB Output is correct
24 Correct 203 ms 304 KB Output is correct
25 Correct 204 ms 212 KB Output is correct
26 Correct 232 ms 304 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 100 ms 304 KB Output is correct
31 Correct 205 ms 212 KB Output is correct
32 Correct 212 ms 304 KB Output is correct
33 Correct 236 ms 304 KB Output is correct
34 Correct 256 ms 304 KB Output is correct
35 Correct 207 ms 212 KB Output is correct
36 Correct 229 ms 304 KB Output is correct
# 결과 실행 시간 메모리 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 212 KB Output is correct
7 Correct 30 ms 212 KB Output is correct
8 Correct 202 ms 324 KB Output is correct
9 Correct 203 ms 304 KB Output is correct
10 Correct 217 ms 300 KB Output is correct
11 Correct 202 ms 316 KB Output is correct
12 Correct 198 ms 304 KB Output is correct
13 Correct 235 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 0 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 24 ms 320 KB Output is correct
21 Correct 201 ms 304 KB Output is correct
22 Correct 207 ms 304 KB Output is correct
23 Correct 221 ms 304 KB Output is correct
24 Correct 202 ms 300 KB Output is correct
25 Correct 200 ms 212 KB Output is correct
26 Correct 236 ms 308 KB Output is correct
27 Correct 2 ms 1236 KB Output is correct
28 Correct 2 ms 1620 KB Output is correct
29 Correct 4 ms 3460 KB Output is correct
30 Correct 5 ms 4200 KB Output is correct
31 Correct 8 ms 6100 KB Output is correct
32 Correct 7 ms 6100 KB Output is correct
33 Correct 8 ms 6228 KB Output is correct
34 Correct 7 ms 5844 KB Output is correct
35 Correct 7 ms 5844 KB Output is correct
36 Correct 7 ms 5844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 221 ms 304 KB Output is correct
9 Correct 200 ms 304 KB Output is correct
10 Correct 206 ms 304 KB Output is correct
11 Correct 240 ms 312 KB Output is correct
12 Correct 197 ms 312 KB Output is correct
13 Correct 225 ms 308 KB Output is correct
14 Correct 1 ms 1236 KB Output is correct
15 Correct 2 ms 1620 KB Output is correct
16 Correct 4 ms 3412 KB Output is correct
17 Correct 6 ms 4180 KB Output is correct
18 Correct 9 ms 6100 KB Output is correct
19 Correct 7 ms 6100 KB Output is correct
20 Correct 7 ms 6100 KB Output is correct
21 Correct 7 ms 5828 KB Output is correct
22 Correct 8 ms 5844 KB Output is correct
23 Correct 9 ms 5844 KB Output is correct
24 Correct 8 ms 6564 KB Output is correct
25 Correct 15 ms 10748 KB Output is correct
26 Correct 24 ms 15956 KB Output is correct
27 Correct 35 ms 22184 KB Output is correct
28 Correct 50 ms 27020 KB Output is correct
29 Incorrect 46 ms 31180 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
6 Correct 8 ms 328 KB Output is correct
7 Correct 25 ms 332 KB Output is correct
8 Correct 219 ms 300 KB Output is correct
9 Correct 204 ms 300 KB Output is correct
10 Correct 198 ms 212 KB Output is correct
11 Correct 215 ms 332 KB Output is correct
12 Correct 209 ms 300 KB Output is correct
13 Correct 233 ms 300 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 26 ms 212 KB Output is correct
21 Correct 202 ms 304 KB Output is correct
22 Correct 206 ms 304 KB Output is correct
23 Correct 213 ms 308 KB Output is correct
24 Correct 196 ms 212 KB Output is correct
25 Correct 201 ms 304 KB Output is correct
26 Correct 267 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 96 ms 212 KB Output is correct
31 Correct 202 ms 304 KB Output is correct
32 Correct 206 ms 212 KB Output is correct
33 Correct 224 ms 308 KB Output is correct
34 Correct 227 ms 308 KB Output is correct
35 Correct 197 ms 304 KB Output is correct
36 Correct 247 ms 304 KB Output is correct
37 Correct 1 ms 1236 KB Output is correct
38 Correct 3 ms 1620 KB Output is correct
39 Correct 6 ms 3412 KB Output is correct
40 Correct 5 ms 4180 KB Output is correct
41 Correct 8 ms 6108 KB Output is correct
42 Correct 8 ms 6128 KB Output is correct
43 Correct 7 ms 6128 KB Output is correct
44 Correct 8 ms 5844 KB Output is correct
45 Correct 8 ms 5844 KB Output is correct
46 Correct 8 ms 5844 KB Output is correct
47 Correct 8 ms 6484 KB Output is correct
48 Correct 16 ms 10692 KB Output is correct
49 Correct 25 ms 15956 KB Output is correct
50 Correct 35 ms 22160 KB Output is correct
51 Correct 45 ms 26980 KB Output is correct
52 Incorrect 42 ms 31032 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 212 KB Output is correct
7 Correct 24 ms 212 KB Output is correct
8 Correct 257 ms 212 KB Output is correct
9 Correct 204 ms 308 KB Output is correct
10 Correct 220 ms 300 KB Output is correct
11 Correct 199 ms 304 KB Output is correct
12 Correct 210 ms 304 KB Output is correct
13 Correct 256 ms 304 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 212 KB Output is correct
17 Correct 99 ms 300 KB Output is correct
18 Correct 225 ms 300 KB Output is correct
19 Correct 202 ms 300 KB Output is correct
20 Correct 230 ms 212 KB Output is correct
21 Correct 252 ms 312 KB Output is correct
22 Correct 203 ms 300 KB Output is correct
23 Correct 233 ms 212 KB Output is correct
24 Correct 1 ms 1236 KB Output is correct
25 Correct 2 ms 1620 KB Output is correct
26 Correct 6 ms 3540 KB Output is correct
27 Correct 5 ms 4180 KB Output is correct
28 Correct 9 ms 6100 KB Output is correct
29 Correct 7 ms 6120 KB Output is correct
30 Correct 7 ms 6100 KB Output is correct
31 Correct 8 ms 5792 KB Output is correct
32 Correct 9 ms 5860 KB Output is correct
33 Correct 7 ms 5824 KB Output is correct
34 Correct 9 ms 6484 KB Output is correct
35 Correct 16 ms 10668 KB Output is correct
36 Correct 26 ms 15956 KB Output is correct
37 Correct 35 ms 22288 KB Output is correct
38 Correct 48 ms 26964 KB Output is correct
39 Incorrect 40 ms 31120 KB Output isn't correct
40 Halted 0 ms 0 KB -