답안 #43634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43634 2018-03-18T18:15:07 Z Bruteforceman Bali Sculptures (APIO15_sculpture) C++11
50 / 100
96 ms 1240 KB
#include "bits/stdc++.h"
using namespace std;
int a[2005];
int dp[2005];
int n, A, B;
typedef long long Long;
Long p[2005];
 
const int bit = 42;
long long mask;
const int inf = 1e8;
 
void solve (int x) {
	mask ^= 1LL << x;
	for(int i = 1; i <= n; i++) {
		dp[i] = inf;
		for(int j = 0; j < i; j++) {
			long long sum = p[i] - p[j];
			if((sum | mask) == mask) dp[i] = min(dp[i], dp[j] + 1);
		}
	}
	if(dp[n] > B) {
		mask |= (1LL << x);
	}
}
 
int main(int argc, char const *argv[])
{	
	scanf("%d %d %d", &n, &A, &B);
	for(int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	for(int i = 1; i <= n; i++) {
		p[i] = p[i - 1] + a[i];
	}
	for(int i = 0; i <= bit; i++) {
		mask |= 1LL << i;
	}
	for(int x = bit; x >= 0; x--) {
		solve(x);
	}
	printf("%lld\n", mask);
	return 0;
}

Compilation message

sculpture.cpp: In function 'int main(int, const char**)':
sculpture.cpp:29:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &A, &B);
                               ^
sculpture.cpp:31:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a + i);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 1 ms 440 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 2 ms 628 KB Output is correct
9 Correct 1 ms 628 KB Output is correct
10 Correct 2 ms 628 KB Output is correct
11 Correct 1 ms 628 KB Output is correct
12 Correct 2 ms 732 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 2 ms 732 KB Output is correct
15 Incorrect 2 ms 732 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 732 KB Output is correct
2 Correct 2 ms 732 KB Output is correct
3 Correct 2 ms 732 KB Output is correct
4 Correct 2 ms 732 KB Output is correct
5 Correct 2 ms 732 KB Output is correct
6 Correct 2 ms 732 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 1 ms 732 KB Output is correct
9 Correct 1 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 1 ms 732 KB Output is correct
12 Correct 1 ms 732 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 2 ms 732 KB Output is correct
15 Incorrect 1 ms 732 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 732 KB Output is correct
2 Correct 1 ms 732 KB Output is correct
3 Correct 1 ms 732 KB Output is correct
4 Correct 1 ms 732 KB Output is correct
5 Correct 2 ms 732 KB Output is correct
6 Correct 1 ms 732 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 1 ms 732 KB Output is correct
12 Correct 1 ms 732 KB Output is correct
13 Correct 1 ms 732 KB Output is correct
14 Correct 1 ms 732 KB Output is correct
15 Correct 1 ms 732 KB Output is correct
16 Correct 2 ms 732 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 2 ms 732 KB Output is correct
19 Correct 1 ms 732 KB Output is correct
20 Correct 2 ms 732 KB Output is correct
21 Correct 2 ms 732 KB Output is correct
22 Correct 2 ms 732 KB Output is correct
23 Correct 2 ms 732 KB Output is correct
24 Correct 2 ms 732 KB Output is correct
25 Correct 2 ms 732 KB Output is correct
26 Correct 2 ms 732 KB Output is correct
27 Correct 2 ms 732 KB Output is correct
28 Correct 2 ms 732 KB Output is correct
29 Correct 2 ms 732 KB Output is correct
30 Correct 2 ms 732 KB Output is correct
31 Correct 3 ms 732 KB Output is correct
32 Correct 2 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 732 KB Output is correct
2 Correct 2 ms 732 KB Output is correct
3 Correct 1 ms 732 KB Output is correct
4 Correct 2 ms 732 KB Output is correct
5 Correct 1 ms 732 KB Output is correct
6 Correct 2 ms 732 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 1 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 1 ms 732 KB Output is correct
12 Correct 1 ms 732 KB Output is correct
13 Correct 1 ms 732 KB Output is correct
14 Correct 2 ms 732 KB Output is correct
15 Incorrect 2 ms 732 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 732 KB Output is correct
2 Correct 1 ms 732 KB Output is correct
3 Correct 1 ms 732 KB Output is correct
4 Correct 2 ms 732 KB Output is correct
5 Correct 1 ms 732 KB Output is correct
6 Correct 1 ms 732 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 1 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 1 ms 732 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 1 ms 732 KB Output is correct
15 Correct 1 ms 732 KB Output is correct
16 Correct 2 ms 732 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 1 ms 732 KB Output is correct
19 Correct 1 ms 744 KB Output is correct
20 Correct 1 ms 748 KB Output is correct
21 Correct 1 ms 876 KB Output is correct
22 Correct 1 ms 876 KB Output is correct
23 Correct 1 ms 876 KB Output is correct
24 Correct 1 ms 876 KB Output is correct
25 Correct 2 ms 876 KB Output is correct
26 Correct 2 ms 876 KB Output is correct
27 Correct 1 ms 876 KB Output is correct
28 Correct 2 ms 876 KB Output is correct
29 Correct 2 ms 876 KB Output is correct
30 Correct 2 ms 876 KB Output is correct
31 Correct 2 ms 876 KB Output is correct
32 Correct 2 ms 876 KB Output is correct
33 Correct 2 ms 876 KB Output is correct
34 Correct 1 ms 876 KB Output is correct
35 Correct 2 ms 876 KB Output is correct
36 Correct 2 ms 876 KB Output is correct
37 Correct 2 ms 876 KB Output is correct
38 Correct 2 ms 876 KB Output is correct
39 Correct 2 ms 876 KB Output is correct
40 Correct 2 ms 876 KB Output is correct
41 Correct 2 ms 876 KB Output is correct
42 Correct 2 ms 876 KB Output is correct
43 Correct 2 ms 968 KB Output is correct
44 Correct 2 ms 968 KB Output is correct
45 Correct 2 ms 968 KB Output is correct
46 Correct 2 ms 968 KB Output is correct
47 Correct 2 ms 968 KB Output is correct
48 Correct 2 ms 968 KB Output is correct
49 Correct 2 ms 968 KB Output is correct
50 Correct 2 ms 968 KB Output is correct
51 Correct 2 ms 968 KB Output is correct
52 Correct 11 ms 968 KB Output is correct
53 Correct 16 ms 968 KB Output is correct
54 Correct 28 ms 996 KB Output is correct
55 Correct 27 ms 1072 KB Output is correct
56 Correct 91 ms 1072 KB Output is correct
57 Correct 94 ms 1100 KB Output is correct
58 Correct 87 ms 1112 KB Output is correct
59 Correct 85 ms 1112 KB Output is correct
60 Correct 96 ms 1164 KB Output is correct
61 Correct 2 ms 1164 KB Output is correct
62 Correct 15 ms 1164 KB Output is correct
63 Correct 32 ms 1164 KB Output is correct
64 Correct 25 ms 1164 KB Output is correct
65 Correct 51 ms 1240 KB Output is correct
66 Correct 69 ms 1240 KB Output is correct
67 Correct 91 ms 1240 KB Output is correct
68 Correct 94 ms 1240 KB Output is correct
69 Correct 88 ms 1240 KB Output is correct