답안 #99473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99473 2019-03-04T09:47:05 Z Shafin666 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
441 ms 31996 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
typedef long double ld;
using namespace std;

int n, a, b;
ll num[2005], pre[2050];
ll dp[2005], dp2[2005][2005];
ll bit = 43, mask;

ll c(int i, int j) {
	return pre[j] - pre[i-1];
}

void can(int x) {
	mask ^= (1LL << x);

	for(int i = 1; i <= n; i++) {
		dp[i] = 1e18+7;

		for(int j = 0; j < i; j++) {
			if((mask | c(j+1, i)) == mask) dp[i] = min(dp[i], dp[j]+1);
		}
	}
	if(dp[n] > b) mask |= (1LL << x);
}

void can2(int x) {
	mask ^= (1LL << x);

	memset(dp2, 0, sizeof dp2);
	dp2[0][0] = 1;

	for(int k = 1; k <= n; k++) {
		for(int i = 1;  i <= n; i++) {
			for(int j = 0; j < i; j++) {
				if((mask | c(j+1, i)) == mask) dp2[k][i] |= dp2[k-1][j];
			}
		}
	}

	for(int i = a; i <= b; i++) if(dp2[i][n]) return;
	mask |= (1LL << x);
}

int main() 
{
	cin >> n >> a >> b;

	ll mn = 1e18+7;

	for(int i = 1; i <= n; i++) cin >> num[i];
	for(int i = 1; i <= n; i++) pre[i] = pre[i-1] + num[i];

	for(int i = 0; i <= bit; i++) mask |= (1LL << i);

	for(int i = bit; i >= 0; i--) (a == 1)? can(i) : can2(i);

	cout << mask << endl;

	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:53:5: warning: unused variable 'mn' [-Wunused-variable]
  ll mn = 1e18+7;
     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 319 ms 31872 KB Output is correct
15 Correct 368 ms 31736 KB Output is correct
16 Correct 311 ms 31864 KB Output is correct
17 Correct 321 ms 31864 KB Output is correct
18 Correct 321 ms 31872 KB Output is correct
19 Correct 341 ms 31844 KB Output is correct
20 Correct 322 ms 31864 KB Output is correct
21 Correct 325 ms 31872 KB Output is correct
22 Correct 365 ms 31872 KB Output is correct
23 Correct 393 ms 31872 KB Output is correct
24 Correct 371 ms 31864 KB Output is correct
25 Correct 315 ms 31872 KB Output is correct
26 Correct 321 ms 31996 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 330 ms 31864 KB Output is correct
15 Correct 312 ms 31736 KB Output is correct
16 Correct 316 ms 31864 KB Output is correct
17 Correct 310 ms 31872 KB Output is correct
18 Correct 349 ms 31864 KB Output is correct
19 Correct 322 ms 31992 KB Output is correct
20 Correct 314 ms 31872 KB Output is correct
21 Correct 331 ms 31992 KB Output is correct
22 Correct 321 ms 31864 KB Output is correct
23 Correct 387 ms 31872 KB Output is correct
24 Correct 315 ms 31964 KB Output is correct
25 Correct 315 ms 31736 KB Output is correct
26 Correct 323 ms 31864 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 3 ms 256 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 381 ms 31864 KB Output is correct
15 Correct 317 ms 31864 KB Output is correct
16 Correct 311 ms 31864 KB Output is correct
17 Correct 325 ms 31992 KB Output is correct
18 Correct 326 ms 31992 KB Output is correct
19 Correct 333 ms 31864 KB Output is correct
20 Correct 379 ms 31992 KB Output is correct
21 Correct 352 ms 31864 KB Output is correct
22 Correct 391 ms 31992 KB Output is correct
23 Correct 396 ms 31872 KB Output is correct
24 Correct 322 ms 31864 KB Output is correct
25 Correct 322 ms 31864 KB Output is correct
26 Correct 305 ms 31744 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 3 ms 256 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 3 ms 256 KB Output is correct
54 Correct 3 ms 384 KB Output is correct
55 Correct 3 ms 384 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
57 Correct 3 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
59 Correct 3 ms 384 KB Output is correct
60 Correct 3 ms 384 KB Output is correct
61 Correct 3 ms 384 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 3 ms 384 KB Output is correct
64 Correct 392 ms 31744 KB Output is correct
65 Correct 425 ms 31872 KB Output is correct
66 Correct 359 ms 31864 KB Output is correct
67 Correct 341 ms 31736 KB Output is correct
68 Correct 426 ms 31992 KB Output is correct
69 Correct 393 ms 31864 KB Output is correct
70 Correct 352 ms 31736 KB Output is correct
71 Correct 356 ms 31872 KB Output is correct
72 Correct 436 ms 31864 KB Output is correct
73 Correct 441 ms 31864 KB Output is correct
74 Correct 427 ms 31872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 256 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 3 ms 256 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 3 ms 256 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 4 ms 256 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 2 ms 256 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 3 ms 256 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 12 ms 384 KB Output is correct
53 Correct 19 ms 384 KB Output is correct
54 Correct 29 ms 504 KB Output is correct
55 Correct 36 ms 384 KB Output is correct
56 Correct 95 ms 440 KB Output is correct
57 Correct 99 ms 384 KB Output is correct
58 Correct 103 ms 384 KB Output is correct
59 Correct 105 ms 384 KB Output is correct
60 Correct 126 ms 504 KB Output is correct
61 Correct 1 ms 384 KB Output is correct
62 Correct 17 ms 384 KB Output is correct
63 Correct 31 ms 384 KB Output is correct
64 Correct 31 ms 384 KB Output is correct
65 Correct 51 ms 384 KB Output is correct
66 Correct 76 ms 440 KB Output is correct
67 Correct 108 ms 384 KB Output is correct
68 Correct 108 ms 384 KB Output is correct
69 Correct 97 ms 504 KB Output is correct