# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101325 | 2019-03-18T12:58:14 Z | arman_ferdous | Bali Sculptures (APIO15_sculpture) | C++17 | 186 ms | 512 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2010; int n, A, B; ll a[N], mask, bitpos; int dp4[105][105]; int DP4(int pos, int parts) { if(pos > n) { if(A <= parts && parts <= B) return 1; return 0; } if(dp4[pos][parts] != -1) return dp4[pos][parts]; int &ret = dp4[pos][parts]; ret = 0; ll s = 0; for(int i = pos; i <= n; i++) { s += a[i]; if(((mask >> bitpos) & (s >> bitpos)) == (s>>bitpos)) ret |= DP4(i+1, parts+1); } return ret; } int dp5[N]; int DP5(int pos) { if(pos > n) return 0; if(dp5[pos] != -1) return dp5[pos]; int &ret = dp5[pos]; ret = N; ll s = 0; for(int i = pos; i <= n; i++) { s += a[i]; if(((mask >> bitpos) & (s >> bitpos)) == (s>>bitpos)) ret = min(ret, DP5(i+1) + 1); } return ret; } int main() { scanf("%d %d %d", &n, &A, &B); for(int i = 1; i <= n; i++) scanf("%lld", &a[i]); for(bitpos = 45; bitpos >= 0; bitpos--) { if(A == 1) { memset(dp5, -1, sizeof dp5); if(DP5(1) > B) mask |= (1ll<<bitpos); } else { memset(dp4, -1, sizeof dp4); if(!DP4(1,0)) mask |= (1ll<<bitpos); } } printf("%lld\n", mask); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 432 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 | 384 KB | Output is correct |
13 | Correct | 3 ms | 284 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 | 3 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 | 3 ms | 384 KB | Output is correct |
21 | Correct | 4 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 356 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 256 KB | Output is correct |
30 | Correct | 2 ms | 256 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 256 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 384 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 | 256 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 | 1 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 | 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 | 3 ms | 256 KB | Output is correct |
13 | Correct | 3 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 | 3 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 304 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 0 ms | 256 KB | Output is correct |
28 | Correct | 3 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 | 3 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 3 ms | 384 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 | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
8 | Correct | 3 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 | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 3 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 | 3 ms | 256 KB | Output is correct |
22 | Correct | 3 ms | 256 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 256 KB | Output is correct |
25 | Correct | 3 ms | 256 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 | 256 KB | Output is correct |
29 | Correct | 3 ms | 384 KB | Output is correct |
30 | Correct | 4 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 0 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 256 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 256 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 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 | 3 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 356 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 444 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
24 | Correct | 3 ms | 356 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 256 KB | Output is correct |
28 | Correct | 3 ms | 256 KB | Output is correct |
29 | Correct | 3 ms | 300 KB | Output is correct |
30 | Correct | 3 ms | 256 KB | Output is correct |
31 | Correct | 2 ms | 256 KB | Output is correct |
32 | Correct | 2 ms | 256 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 | 3 ms | 256 KB | Output is correct |
37 | Correct | 1 ms | 256 KB | Output is correct |
38 | Correct | 1 ms | 256 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 | 256 KB | Output is correct |
43 | Correct | 3 ms | 256 KB | Output is correct |
44 | Correct | 2 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 256 KB | Output is correct |
46 | Correct | 3 ms | 256 KB | Output is correct |
47 | Correct | 3 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 256 KB | Output is correct |
49 | Correct | 4 ms | 384 KB | Output is correct |
50 | Correct | 3 ms | 256 KB | Output is correct |
51 | Correct | 3 ms | 384 KB | Output is correct |
52 | Correct | 4 ms | 256 KB | Output is correct |
53 | Correct | 3 ms | 384 KB | Output is correct |
54 | Correct | 4 ms | 384 KB | Output is correct |
55 | Correct | 3 ms | 384 KB | Output is correct |
56 | Correct | 2 ms | 384 KB | Output is correct |
57 | Correct | 3 ms | 384 KB | Output is correct |
58 | Correct | 3 ms | 256 KB | Output is correct |
59 | Correct | 3 ms | 384 KB | Output is correct |
60 | Correct | 2 ms | 256 KB | Output is correct |
61 | Correct | 3 ms | 384 KB | Output is correct |
62 | Correct | 2 ms | 384 KB | Output is correct |
63 | Correct | 2 ms | 384 KB | Output is correct |
64 | Correct | 37 ms | 384 KB | Output is correct |
65 | Correct | 5 ms | 384 KB | Output is correct |
66 | Correct | 7 ms | 384 KB | Output is correct |
67 | Correct | 13 ms | 412 KB | Output is correct |
68 | Correct | 14 ms | 384 KB | Output is correct |
69 | Correct | 27 ms | 356 KB | Output is correct |
70 | Correct | 17 ms | 416 KB | Output is correct |
71 | Correct | 22 ms | 416 KB | Output is correct |
72 | Correct | 22 ms | 384 KB | Output is correct |
73 | Correct | 28 ms | 444 KB | Output is correct |
74 | Correct | 31 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 356 KB | Output is correct |
7 | Correct | 2 ms | 256 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 | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 3 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 | 0 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 256 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 368 KB | Output is correct |
21 | Correct | 3 ms | 256 KB | Output is correct |
22 | Correct | 2 ms | 256 KB | Output is correct |
23 | Correct | 2 ms | 256 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 2 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 | 1 ms | 384 KB | Output is correct |
30 | Correct | 3 ms | 252 KB | Output is correct |
31 | Correct | 2 ms | 256 KB | Output is correct |
32 | Correct | 3 ms | 384 KB | Output is correct |
33 | Correct | 3 ms | 444 KB | Output is correct |
34 | Correct | 3 ms | 384 KB | Output is correct |
35 | Correct | 3 ms | 256 KB | Output is correct |
36 | Correct | 3 ms | 384 KB | Output is correct |
37 | Correct | 0 ms | 256 KB | Output is correct |
38 | Correct | 3 ms | 256 KB | Output is correct |
39 | Correct | 4 ms | 384 KB | Output is correct |
40 | Correct | 3 ms | 384 KB | Output is correct |
41 | Correct | 4 ms | 256 KB | Output is correct |
42 | Correct | 3 ms | 384 KB | Output is correct |
43 | Correct | 4 ms | 384 KB | Output is correct |
44 | Correct | 2 ms | 256 KB | Output is correct |
45 | Correct | 2 ms | 256 KB | Output is correct |
46 | Correct | 3 ms | 384 KB | Output is correct |
47 | Correct | 3 ms | 256 KB | Output is correct |
48 | Correct | 3 ms | 384 KB | Output is correct |
49 | Correct | 2 ms | 384 KB | Output is correct |
50 | Correct | 3 ms | 256 KB | Output is correct |
51 | Correct | 2 ms | 384 KB | Output is correct |
52 | Correct | 14 ms | 384 KB | Output is correct |
53 | Correct | 14 ms | 384 KB | Output is correct |
54 | Correct | 47 ms | 384 KB | Output is correct |
55 | Correct | 36 ms | 420 KB | Output is correct |
56 | Correct | 91 ms | 508 KB | Output is correct |
57 | Correct | 92 ms | 476 KB | Output is correct |
58 | Correct | 117 ms | 504 KB | Output is correct |
59 | Correct | 143 ms | 472 KB | Output is correct |
60 | Correct | 98 ms | 512 KB | Output is correct |
61 | Correct | 3 ms | 256 KB | Output is correct |
62 | Correct | 17 ms | 384 KB | Output is correct |
63 | Correct | 79 ms | 392 KB | Output is correct |
64 | Correct | 24 ms | 384 KB | Output is correct |
65 | Correct | 43 ms | 512 KB | Output is correct |
66 | Correct | 67 ms | 384 KB | Output is correct |
67 | Correct | 92 ms | 384 KB | Output is correct |
68 | Correct | 186 ms | 508 KB | Output is correct |
69 | Correct | 92 ms | 384 KB | Output is correct |