답안 #402201

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402201 2021-05-11T12:24:30 Z yoavL Bali Sculptures (APIO15_sculpture) C++14
9 / 100
1000 ms 332 KB
#include <iostream>
#include <vector>
#include <algorithm>

#define upmax(a, b) a = max(a, b);
#define upmin(a, b) a = min(a, b);
#define pr(x) cout << x << endl;

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll inf = 1e18;
ll n, a, b;
vll arr;
ll ans;

void brute(vll& div, ll ind)
{
	if (ind == n) {
		if (div.size() < a-1 || div.size() > b-1) return;
		ll res = 0;
		ll cursum = 0;
		ll p = 0;
		for (ll i = 0; i < n; i++) {
			cursum += arr[i];
			if (p < div.size() && div[p] == i) {
				res |= cursum;
				p++;
				cursum = 0;
			}
		}
		res |= cursum;
		upmin(ans, res);
		return;
	}

	div.push_back(ind);
	if(ind < n-1) brute(div, ind + 1);
	div.pop_back();
	brute(div, ind + 1);
}

int main()
{
	cin >> n >> a >> b;
	arr.resize(n);
	for (ll i = 0; i < n; i++) cin >> arr[i];

	ans = inf;
	vll div;
	brute(div, 0);
	pr(ans);
}

/*

6 1 3 
8 1 2 1 5 4


*/

Compilation message

sculpture.cpp: In function 'void brute(vll&, ll)':
sculpture.cpp:22:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |   if (div.size() < a-1 || div.size() > b-1) return;
      |       ~~~~~~~~~~~^~~~~
sculpture.cpp:22:38: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |   if (div.size() < a-1 || div.size() > b-1) return;
      |                           ~~~~~~~~~~~^~~~~
sculpture.cpp:28:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    if (p < div.size() && div[p] == i) {
      |        ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 7 ms 204 KB Output is correct
9 Correct 7 ms 292 KB Output is correct
10 Correct 9 ms 288 KB Output is correct
11 Correct 7 ms 284 KB Output is correct
12 Correct 9 ms 292 KB Output is correct
13 Correct 35 ms 284 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 288 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
21 Correct 11 ms 292 KB Output is correct
22 Correct 10 ms 296 KB Output is correct
23 Correct 11 ms 288 KB Output is correct
24 Correct 7 ms 288 KB Output is correct
25 Correct 12 ms 204 KB Output is correct
26 Correct 33 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 5 ms 204 KB Output is correct
31 Correct 10 ms 204 KB Output is correct
32 Correct 9 ms 204 KB Output is correct
33 Correct 32 ms 204 KB Output is correct
34 Correct 38 ms 204 KB Output is correct
35 Correct 7 ms 204 KB Output is correct
36 Correct 41 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 10 ms 204 KB Output is correct
9 Correct 9 ms 296 KB Output is correct
10 Correct 9 ms 292 KB Output is correct
11 Correct 7 ms 292 KB Output is correct
12 Correct 7 ms 204 KB Output is correct
13 Correct 43 ms 276 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 288 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
21 Correct 10 ms 292 KB Output is correct
22 Correct 11 ms 292 KB Output is correct
23 Correct 10 ms 292 KB Output is correct
24 Correct 7 ms 204 KB Output is correct
25 Correct 10 ms 204 KB Output is correct
26 Correct 31 ms 204 KB Output is correct
27 Correct 65 ms 204 KB Output is correct
28 Correct 386 ms 272 KB Output is correct
29 Execution timed out 1099 ms 204 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 8 ms 204 KB Output is correct
9 Correct 9 ms 204 KB Output is correct
10 Correct 8 ms 332 KB Output is correct
11 Correct 7 ms 204 KB Output is correct
12 Correct 9 ms 288 KB Output is correct
13 Correct 33 ms 272 KB Output is correct
14 Correct 66 ms 204 KB Output is correct
15 Correct 380 ms 268 KB Output is correct
16 Execution timed out 1083 ms 204 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 7 ms 288 KB Output is correct
9 Correct 7 ms 204 KB Output is correct
10 Correct 7 ms 204 KB Output is correct
11 Correct 7 ms 204 KB Output is correct
12 Correct 7 ms 292 KB Output is correct
13 Correct 33 ms 272 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 288 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
21 Correct 10 ms 296 KB Output is correct
22 Correct 10 ms 296 KB Output is correct
23 Correct 11 ms 288 KB Output is correct
24 Correct 8 ms 292 KB Output is correct
25 Correct 10 ms 204 KB Output is correct
26 Correct 38 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 4 ms 288 KB Output is correct
31 Correct 12 ms 288 KB Output is correct
32 Correct 9 ms 296 KB Output is correct
33 Correct 33 ms 268 KB Output is correct
34 Correct 40 ms 204 KB Output is correct
35 Correct 7 ms 204 KB Output is correct
36 Correct 33 ms 204 KB Output is correct
37 Correct 65 ms 204 KB Output is correct
38 Correct 393 ms 268 KB Output is correct
39 Execution timed out 1082 ms 204 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 9 ms 204 KB Output is correct
9 Correct 8 ms 304 KB Output is correct
10 Correct 8 ms 296 KB Output is correct
11 Correct 9 ms 212 KB Output is correct
12 Correct 8 ms 292 KB Output is correct
13 Correct 37 ms 204 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 5 ms 204 KB Output is correct
18 Correct 11 ms 292 KB Output is correct
19 Correct 7 ms 208 KB Output is correct
20 Correct 32 ms 204 KB Output is correct
21 Correct 37 ms 204 KB Output is correct
22 Correct 7 ms 204 KB Output is correct
23 Correct 36 ms 204 KB Output is correct
24 Correct 81 ms 268 KB Output is correct
25 Correct 425 ms 272 KB Output is correct
26 Execution timed out 1073 ms 208 KB Time limit exceeded
27 Halted 0 ms 0 KB -