답안 #70652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70652 2018-08-23T08:15:20 Z evpipis Bali Sculptures (APIO15_sculpture) C++11
71 / 100
54 ms 2084 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int inf = 1e9;
int dp1[105][105], dp2[2005], n, a, b, arr[2005];

bool solve1(ll x){
    dp1[n+1][0] = 1;
    for (int i = n; i >= 1; i--)
        for (int k = 1; k <= b; k++){
            ll sum = 0;
            dp1[i][k] = 0;
            for (int j = i; j <= n; j++){
                sum += arr[j];
                if ((sum|x) == x)
                    dp1[i][k] |= dp1[j+1][k-1];
            }
        }

    for (int k = a; k <= b; k++)
        if (dp1[1][k]) return true;
    return false;
}

bool solve2(ll x){
    for (int i = n; i >= 1; i--){
        ll sum = 0;
        for (int j = i; j <= n; j++){
            sum += arr[j];
            dp2[i] = inf;
            if ((sum|x) == x)
                dp2[i] = min(dp2[i], dp2[j+1]+1);
        }
    }

    return (dp2[1] <= b);
}

int main(){
    scanf("%d %d %d", &n, &a, &b);
    for (int i = 1; i <= n; i++)
        scanf("%d", &arr[i]);

    ll ans = (1LL<<41)-1;
    for (int j = 40; j >= 0; j--){
        if (solve1(ans^(1LL<<j)))
            ans ^= (1LL<<j);
        //if (a == 1 && solve2(ans^(1LL<<j)))
          //  ans ^= (1LL<<j);
    }

    printf("%lld\n", ans);
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:41:10: 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:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 360 KB Output is correct
3 Correct 3 ms 472 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 3 ms 700 KB Output is correct
7 Correct 3 ms 704 KB Output is correct
8 Correct 3 ms 708 KB Output is correct
9 Correct 3 ms 712 KB Output is correct
10 Correct 3 ms 748 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 3 ms 772 KB Output is correct
13 Correct 3 ms 784 KB Output is correct
14 Correct 2 ms 784 KB Output is correct
15 Correct 3 ms 912 KB Output is correct
16 Correct 3 ms 912 KB Output is correct
17 Correct 2 ms 916 KB Output is correct
18 Correct 2 ms 920 KB Output is correct
19 Correct 3 ms 920 KB Output is correct
20 Correct 3 ms 920 KB Output is correct
21 Correct 3 ms 920 KB Output is correct
22 Correct 3 ms 920 KB Output is correct
23 Correct 3 ms 920 KB Output is correct
24 Correct 3 ms 920 KB Output is correct
25 Correct 2 ms 920 KB Output is correct
26 Correct 4 ms 920 KB Output is correct
27 Correct 3 ms 920 KB Output is correct
28 Correct 3 ms 920 KB Output is correct
29 Correct 3 ms 920 KB Output is correct
30 Correct 3 ms 920 KB Output is correct
31 Correct 3 ms 968 KB Output is correct
32 Correct 3 ms 968 KB Output is correct
33 Correct 3 ms 968 KB Output is correct
34 Correct 3 ms 968 KB Output is correct
35 Correct 3 ms 968 KB Output is correct
36 Correct 3 ms 968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 968 KB Output is correct
2 Correct 3 ms 968 KB Output is correct
3 Correct 3 ms 968 KB Output is correct
4 Correct 3 ms 968 KB Output is correct
5 Correct 3 ms 968 KB Output is correct
6 Correct 2 ms 968 KB Output is correct
7 Correct 2 ms 968 KB Output is correct
8 Correct 3 ms 968 KB Output is correct
9 Correct 4 ms 968 KB Output is correct
10 Correct 3 ms 968 KB Output is correct
11 Correct 4 ms 968 KB Output is correct
12 Correct 3 ms 968 KB Output is correct
13 Correct 3 ms 968 KB Output is correct
14 Correct 3 ms 968 KB Output is correct
15 Correct 3 ms 968 KB Output is correct
16 Correct 3 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 3 ms 968 KB Output is correct
19 Correct 3 ms 968 KB Output is correct
20 Correct 2 ms 968 KB Output is correct
21 Correct 3 ms 968 KB Output is correct
22 Correct 2 ms 968 KB Output is correct
23 Correct 2 ms 968 KB Output is correct
24 Correct 2 ms 972 KB Output is correct
25 Correct 3 ms 976 KB Output is correct
26 Correct 3 ms 980 KB Output is correct
27 Correct 4 ms 988 KB Output is correct
28 Correct 4 ms 988 KB Output is correct
29 Correct 4 ms 992 KB Output is correct
30 Correct 4 ms 1000 KB Output is correct
31 Correct 5 ms 1132 KB Output is correct
32 Correct 5 ms 1132 KB Output is correct
33 Correct 3 ms 1132 KB Output is correct
34 Correct 4 ms 1132 KB Output is correct
35 Correct 6 ms 1132 KB Output is correct
36 Correct 4 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1132 KB Output is correct
2 Correct 3 ms 1148 KB Output is correct
3 Correct 3 ms 1148 KB Output is correct
4 Correct 3 ms 1172 KB Output is correct
5 Correct 3 ms 1192 KB Output is correct
6 Correct 3 ms 1196 KB Output is correct
7 Correct 3 ms 1312 KB Output is correct
8 Correct 3 ms 1312 KB Output is correct
9 Correct 3 ms 1312 KB Output is correct
10 Correct 3 ms 1312 KB Output is correct
11 Correct 3 ms 1312 KB Output is correct
12 Correct 2 ms 1312 KB Output is correct
13 Correct 3 ms 1312 KB Output is correct
14 Correct 4 ms 1312 KB Output is correct
15 Correct 3 ms 1312 KB Output is correct
16 Correct 3 ms 1312 KB Output is correct
17 Correct 4 ms 1312 KB Output is correct
18 Correct 5 ms 1312 KB Output is correct
19 Correct 5 ms 1312 KB Output is correct
20 Correct 4 ms 1312 KB Output is correct
21 Correct 5 ms 1312 KB Output is correct
22 Correct 4 ms 1312 KB Output is correct
23 Correct 3 ms 1312 KB Output is correct
24 Correct 5 ms 1312 KB Output is correct
25 Correct 5 ms 1312 KB Output is correct
26 Correct 9 ms 1312 KB Output is correct
27 Correct 25 ms 1312 KB Output is correct
28 Correct 48 ms 1316 KB Output is correct
29 Correct 51 ms 1320 KB Output is correct
30 Correct 2 ms 1412 KB Output is correct
31 Correct 23 ms 1412 KB Output is correct
32 Correct 42 ms 1412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1412 KB Output is correct
2 Correct 2 ms 1412 KB Output is correct
3 Correct 3 ms 1412 KB Output is correct
4 Correct 3 ms 1412 KB Output is correct
5 Correct 3 ms 1412 KB Output is correct
6 Correct 4 ms 1412 KB Output is correct
7 Correct 3 ms 1412 KB Output is correct
8 Correct 3 ms 1412 KB Output is correct
9 Correct 3 ms 1412 KB Output is correct
10 Correct 3 ms 1412 KB Output is correct
11 Correct 2 ms 1412 KB Output is correct
12 Correct 3 ms 1412 KB Output is correct
13 Correct 3 ms 1412 KB Output is correct
14 Correct 2 ms 1412 KB Output is correct
15 Correct 2 ms 1412 KB Output is correct
16 Correct 2 ms 1412 KB Output is correct
17 Correct 3 ms 1412 KB Output is correct
18 Correct 3 ms 1412 KB Output is correct
19 Correct 2 ms 1416 KB Output is correct
20 Correct 3 ms 1416 KB Output is correct
21 Correct 3 ms 1416 KB Output is correct
22 Correct 3 ms 1428 KB Output is correct
23 Correct 3 ms 1432 KB Output is correct
24 Correct 3 ms 1560 KB Output is correct
25 Correct 2 ms 1560 KB Output is correct
26 Correct 3 ms 1560 KB Output is correct
27 Correct 3 ms 1560 KB Output is correct
28 Correct 2 ms 1560 KB Output is correct
29 Correct 3 ms 1560 KB Output is correct
30 Correct 2 ms 1560 KB Output is correct
31 Correct 2 ms 1560 KB Output is correct
32 Correct 2 ms 1560 KB Output is correct
33 Correct 4 ms 1560 KB Output is correct
34 Correct 3 ms 1560 KB Output is correct
35 Correct 3 ms 1560 KB Output is correct
36 Correct 4 ms 1560 KB Output is correct
37 Correct 3 ms 1560 KB Output is correct
38 Correct 3 ms 1560 KB Output is correct
39 Correct 4 ms 1560 KB Output is correct
40 Correct 5 ms 1560 KB Output is correct
41 Correct 5 ms 1560 KB Output is correct
42 Correct 6 ms 1668 KB Output is correct
43 Correct 2 ms 1668 KB Output is correct
44 Correct 5 ms 1668 KB Output is correct
45 Correct 5 ms 1668 KB Output is correct
46 Correct 4 ms 1668 KB Output is correct
47 Correct 5 ms 1668 KB Output is correct
48 Correct 4 ms 1668 KB Output is correct
49 Correct 10 ms 1668 KB Output is correct
50 Correct 28 ms 1668 KB Output is correct
51 Correct 52 ms 1668 KB Output is correct
52 Correct 50 ms 1668 KB Output is correct
53 Correct 3 ms 1668 KB Output is correct
54 Correct 29 ms 1680 KB Output is correct
55 Correct 40 ms 1680 KB Output is correct
56 Correct 5 ms 1680 KB Output is correct
57 Correct 10 ms 1700 KB Output is correct
58 Correct 18 ms 1700 KB Output is correct
59 Correct 32 ms 1700 KB Output is correct
60 Correct 36 ms 1700 KB Output is correct
61 Correct 3 ms 1700 KB Output is correct
62 Correct 42 ms 1700 KB Output is correct
63 Correct 41 ms 1700 KB Output is correct
64 Correct 36 ms 1716 KB Output is correct
65 Correct 6 ms 1852 KB Output is correct
66 Correct 4 ms 1852 KB Output is correct
67 Correct 8 ms 1852 KB Output is correct
68 Correct 18 ms 1852 KB Output is correct
69 Correct 41 ms 1852 KB Output is correct
70 Correct 37 ms 1852 KB Output is correct
71 Correct 3 ms 1852 KB Output is correct
72 Correct 41 ms 1852 KB Output is correct
73 Correct 32 ms 1852 KB Output is correct
74 Correct 29 ms 1852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1852 KB Output is correct
2 Correct 2 ms 1852 KB Output is correct
3 Correct 3 ms 1852 KB Output is correct
4 Correct 3 ms 1852 KB Output is correct
5 Correct 2 ms 1852 KB Output is correct
6 Correct 3 ms 1852 KB Output is correct
7 Correct 3 ms 1852 KB Output is correct
8 Correct 3 ms 1852 KB Output is correct
9 Correct 3 ms 1852 KB Output is correct
10 Correct 3 ms 1852 KB Output is correct
11 Correct 3 ms 1852 KB Output is correct
12 Correct 2 ms 1852 KB Output is correct
13 Correct 3 ms 1852 KB Output is correct
14 Correct 2 ms 1852 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1884 KB Output is correct
18 Correct 3 ms 1884 KB Output is correct
19 Correct 3 ms 1884 KB Output is correct
20 Correct 3 ms 1884 KB Output is correct
21 Correct 3 ms 1884 KB Output is correct
22 Correct 3 ms 1920 KB Output is correct
23 Correct 3 ms 1920 KB Output is correct
24 Correct 4 ms 1920 KB Output is correct
25 Correct 3 ms 1920 KB Output is correct
26 Correct 3 ms 1932 KB Output is correct
27 Correct 5 ms 1932 KB Output is correct
28 Correct 5 ms 1932 KB Output is correct
29 Correct 6 ms 1932 KB Output is correct
30 Correct 3 ms 1932 KB Output is correct
31 Correct 4 ms 1932 KB Output is correct
32 Correct 5 ms 2000 KB Output is correct
33 Correct 5 ms 2000 KB Output is correct
34 Correct 5 ms 2000 KB Output is correct
35 Correct 4 ms 2000 KB Output is correct
36 Correct 9 ms 2000 KB Output is correct
37 Correct 29 ms 2000 KB Output is correct
38 Correct 54 ms 2000 KB Output is correct
39 Correct 52 ms 2000 KB Output is correct
40 Correct 4 ms 2000 KB Output is correct
41 Correct 26 ms 2000 KB Output is correct
42 Correct 39 ms 2000 KB Output is correct
43 Correct 5 ms 2000 KB Output is correct
44 Correct 8 ms 2000 KB Output is correct
45 Correct 19 ms 2000 KB Output is correct
46 Correct 32 ms 2000 KB Output is correct
47 Correct 31 ms 2064 KB Output is correct
48 Correct 3 ms 2064 KB Output is correct
49 Correct 38 ms 2064 KB Output is correct
50 Correct 34 ms 2064 KB Output is correct
51 Correct 12 ms 2064 KB Output is correct
52 Runtime error 3 ms 2084 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -