답안 #40736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40736 2018-02-07T16:57:12 Z bogdan10bos Bali Sculptures (APIO15_sculpture) C++14
100 / 100
107 ms 1192 KB
#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

typedef long long LL;

int N, A, B;
int v[2005];
LL s[2005];
LL ans;
int dp1[2005];
int dp[105][105];

bool can(int b)
{
    LL pw = (1LL << b);
    if(A == 1)
    {
        dp1[0] = 0;
        for(int i = 1; i <= N; i++)
        {
            dp1[i] = N + 1;
            for(int j = 0; j < i; j++)
                if( ( (s[i] - s[j]) & (~ans) ) < pw )
                    dp1[i] = min(dp1[i], dp1[j] + 1);
        }
        return (dp1[N] <= B);
    }

    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= B; j++)
        {
            dp[i][j] = 0;
            for(int k = 0; k < i; k++)
                if( ( (s[i] - s[k]) & (~ans) ) < pw )
                    dp[i][j] |= dp[k][j - 1];
        }

    for(int i = A; i <= B; i++)
        if(dp[N][i])    return true;
    return false;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d%d", &N, &A, &B);
    for(int i = 1; i <= N; i++) scanf("%d", &v[i]), s[i] = s[i - 1] + v[i];

    ans = 0;
    for(int b = 41; b >= 0; b--)
        if( !can(b) )
            ans ^= (1LL << b);

    printf("%lld\n", ans);

    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:55:32: 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:56:75: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= N; i++) scanf("%d", &v[i]), s[i] = s[i - 1] + v[i];
                                                                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 528 KB Output is correct
5 Correct 1 ms 528 KB Output is correct
6 Correct 1 ms 528 KB Output is correct
7 Correct 2 ms 528 KB Output is correct
8 Correct 1 ms 528 KB Output is correct
9 Correct 1 ms 528 KB Output is correct
10 Correct 1 ms 528 KB Output is correct
11 Correct 2 ms 548 KB Output is correct
12 Correct 2 ms 600 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 1 ms 620 KB Output is correct
15 Correct 2 ms 704 KB Output is correct
16 Correct 2 ms 704 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 704 KB Output is correct
19 Correct 2 ms 704 KB Output is correct
20 Correct 1 ms 704 KB Output is correct
21 Correct 2 ms 704 KB Output is correct
22 Correct 2 ms 748 KB Output is correct
23 Correct 2 ms 748 KB Output is correct
24 Correct 2 ms 748 KB Output is correct
25 Correct 2 ms 748 KB Output is correct
26 Correct 2 ms 796 KB Output is correct
27 Correct 2 ms 796 KB Output is correct
28 Correct 1 ms 796 KB Output is correct
29 Correct 2 ms 796 KB Output is correct
30 Correct 2 ms 796 KB Output is correct
31 Correct 1 ms 796 KB Output is correct
32 Correct 1 ms 796 KB Output is correct
33 Correct 2 ms 884 KB Output is correct
34 Correct 1 ms 884 KB Output is correct
35 Correct 2 ms 884 KB Output is correct
36 Correct 2 ms 884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 884 KB Output is correct
2 Correct 1 ms 884 KB Output is correct
3 Correct 1 ms 884 KB Output is correct
4 Correct 1 ms 884 KB Output is correct
5 Correct 1 ms 884 KB Output is correct
6 Correct 1 ms 884 KB Output is correct
7 Correct 1 ms 884 KB Output is correct
8 Correct 2 ms 884 KB Output is correct
9 Correct 2 ms 884 KB Output is correct
10 Correct 1 ms 884 KB Output is correct
11 Correct 1 ms 884 KB Output is correct
12 Correct 1 ms 884 KB Output is correct
13 Correct 2 ms 884 KB Output is correct
14 Correct 1 ms 884 KB Output is correct
15 Correct 1 ms 884 KB Output is correct
16 Correct 1 ms 884 KB Output is correct
17 Correct 1 ms 884 KB Output is correct
18 Correct 2 ms 884 KB Output is correct
19 Correct 2 ms 884 KB Output is correct
20 Correct 1 ms 884 KB Output is correct
21 Correct 2 ms 884 KB Output is correct
22 Correct 2 ms 884 KB Output is correct
23 Correct 2 ms 884 KB Output is correct
24 Correct 1 ms 884 KB Output is correct
25 Correct 2 ms 884 KB Output is correct
26 Correct 2 ms 884 KB Output is correct
27 Correct 2 ms 884 KB Output is correct
28 Correct 1 ms 888 KB Output is correct
29 Correct 1 ms 888 KB Output is correct
30 Correct 2 ms 888 KB Output is correct
31 Correct 2 ms 888 KB Output is correct
32 Correct 1 ms 888 KB Output is correct
33 Correct 1 ms 888 KB Output is correct
34 Correct 1 ms 888 KB Output is correct
35 Correct 1 ms 888 KB Output is correct
36 Correct 2 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 888 KB Output is correct
2 Correct 1 ms 888 KB Output is correct
3 Correct 1 ms 888 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 1 ms 888 KB Output is correct
6 Correct 2 ms 888 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 2 ms 888 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 1 ms 888 KB Output is correct
11 Correct 1 ms 888 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 968 KB Output is correct
14 Correct 1 ms 968 KB Output is correct
15 Correct 1 ms 968 KB Output is correct
16 Correct 1 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 2 ms 968 KB Output is correct
19 Correct 1 ms 968 KB Output is correct
20 Correct 1 ms 968 KB Output is correct
21 Correct 1 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 968 KB Output is correct
25 Correct 2 ms 968 KB Output is correct
26 Correct 2 ms 968 KB Output is correct
27 Correct 2 ms 968 KB Output is correct
28 Correct 2 ms 968 KB Output is correct
29 Correct 2 ms 968 KB Output is correct
30 Correct 3 ms 968 KB Output is correct
31 Correct 2 ms 968 KB Output is correct
32 Correct 2 ms 968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 968 KB Output is correct
2 Correct 1 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 1 ms 968 KB Output is correct
5 Correct 1 ms 968 KB Output is correct
6 Correct 1 ms 968 KB Output is correct
7 Correct 1 ms 968 KB Output is correct
8 Correct 1 ms 968 KB Output is correct
9 Correct 1 ms 968 KB Output is correct
10 Correct 1 ms 968 KB Output is correct
11 Correct 1 ms 968 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 2 ms 968 KB Output is correct
14 Correct 2 ms 968 KB Output is correct
15 Correct 2 ms 968 KB Output is correct
16 Correct 2 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 2 ms 968 KB Output is correct
19 Correct 2 ms 968 KB Output is correct
20 Correct 1 ms 968 KB Output is correct
21 Correct 2 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 968 KB Output is correct
25 Correct 2 ms 968 KB Output is correct
26 Correct 2 ms 968 KB Output is correct
27 Correct 1 ms 968 KB Output is correct
28 Correct 1 ms 968 KB Output is correct
29 Correct 1 ms 968 KB Output is correct
30 Correct 1 ms 968 KB Output is correct
31 Correct 1 ms 968 KB Output is correct
32 Correct 1 ms 968 KB Output is correct
33 Correct 1 ms 968 KB Output is correct
34 Correct 1 ms 968 KB Output is correct
35 Correct 1 ms 968 KB Output is correct
36 Correct 1 ms 968 KB Output is correct
37 Correct 1 ms 1024 KB Output is correct
38 Correct 2 ms 1024 KB Output is correct
39 Correct 1 ms 1024 KB Output is correct
40 Correct 1 ms 1024 KB Output is correct
41 Correct 2 ms 1024 KB Output is correct
42 Correct 2 ms 1024 KB Output is correct
43 Correct 2 ms 1024 KB Output is correct
44 Correct 2 ms 1024 KB Output is correct
45 Correct 2 ms 1048 KB Output is correct
46 Correct 2 ms 1048 KB Output is correct
47 Correct 2 ms 1048 KB Output is correct
48 Correct 2 ms 1048 KB Output is correct
49 Correct 2 ms 1048 KB Output is correct
50 Correct 2 ms 1048 KB Output is correct
51 Correct 2 ms 1048 KB Output is correct
52 Correct 2 ms 1048 KB Output is correct
53 Correct 2 ms 1088 KB Output is correct
54 Correct 2 ms 1096 KB Output is correct
55 Correct 2 ms 1096 KB Output is correct
56 Correct 2 ms 1096 KB Output is correct
57 Correct 2 ms 1096 KB Output is correct
58 Correct 2 ms 1096 KB Output is correct
59 Correct 2 ms 1096 KB Output is correct
60 Correct 2 ms 1116 KB Output is correct
61 Correct 2 ms 1120 KB Output is correct
62 Correct 2 ms 1120 KB Output is correct
63 Correct 2 ms 1120 KB Output is correct
64 Correct 36 ms 1120 KB Output is correct
65 Correct 4 ms 1120 KB Output is correct
66 Correct 3 ms 1120 KB Output is correct
67 Correct 6 ms 1120 KB Output is correct
68 Correct 19 ms 1160 KB Output is correct
69 Correct 33 ms 1160 KB Output is correct
70 Correct 40 ms 1160 KB Output is correct
71 Correct 3 ms 1160 KB Output is correct
72 Correct 38 ms 1160 KB Output is correct
73 Correct 36 ms 1176 KB Output is correct
74 Correct 29 ms 1176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1176 KB Output is correct
2 Correct 1 ms 1176 KB Output is correct
3 Correct 1 ms 1176 KB Output is correct
4 Correct 2 ms 1176 KB Output is correct
5 Correct 2 ms 1176 KB Output is correct
6 Correct 1 ms 1184 KB Output is correct
7 Correct 2 ms 1184 KB Output is correct
8 Correct 1 ms 1184 KB Output is correct
9 Correct 2 ms 1184 KB Output is correct
10 Correct 1 ms 1184 KB Output is correct
11 Correct 2 ms 1184 KB Output is correct
12 Correct 1 ms 1184 KB Output is correct
13 Correct 1 ms 1184 KB Output is correct
14 Correct 1 ms 1184 KB Output is correct
15 Correct 1 ms 1184 KB Output is correct
16 Correct 1 ms 1184 KB Output is correct
17 Correct 1 ms 1184 KB Output is correct
18 Correct 1 ms 1184 KB Output is correct
19 Correct 1 ms 1184 KB Output is correct
20 Correct 2 ms 1184 KB Output is correct
21 Correct 1 ms 1184 KB Output is correct
22 Correct 1 ms 1184 KB Output is correct
23 Correct 1 ms 1184 KB Output is correct
24 Correct 1 ms 1184 KB Output is correct
25 Correct 1 ms 1184 KB Output is correct
26 Correct 1 ms 1184 KB Output is correct
27 Correct 1 ms 1184 KB Output is correct
28 Correct 2 ms 1184 KB Output is correct
29 Correct 2 ms 1184 KB Output is correct
30 Correct 2 ms 1184 KB Output is correct
31 Correct 2 ms 1184 KB Output is correct
32 Correct 1 ms 1184 KB Output is correct
33 Correct 2 ms 1184 KB Output is correct
34 Correct 1 ms 1184 KB Output is correct
35 Correct 2 ms 1184 KB Output is correct
36 Correct 2 ms 1184 KB Output is correct
37 Correct 2 ms 1184 KB Output is correct
38 Correct 2 ms 1192 KB Output is correct
39 Correct 2 ms 1192 KB Output is correct
40 Correct 2 ms 1192 KB Output is correct
41 Correct 2 ms 1192 KB Output is correct
42 Correct 2 ms 1192 KB Output is correct
43 Correct 1 ms 1192 KB Output is correct
44 Correct 2 ms 1192 KB Output is correct
45 Correct 2 ms 1192 KB Output is correct
46 Correct 2 ms 1192 KB Output is correct
47 Correct 2 ms 1192 KB Output is correct
48 Correct 2 ms 1192 KB Output is correct
49 Correct 2 ms 1192 KB Output is correct
50 Correct 2 ms 1192 KB Output is correct
51 Correct 2 ms 1192 KB Output is correct
52 Correct 10 ms 1192 KB Output is correct
53 Correct 16 ms 1192 KB Output is correct
54 Correct 29 ms 1192 KB Output is correct
55 Correct 27 ms 1192 KB Output is correct
56 Correct 105 ms 1192 KB Output is correct
57 Correct 100 ms 1192 KB Output is correct
58 Correct 98 ms 1192 KB Output is correct
59 Correct 89 ms 1192 KB Output is correct
60 Correct 107 ms 1192 KB Output is correct
61 Correct 2 ms 1192 KB Output is correct
62 Correct 17 ms 1192 KB Output is correct
63 Correct 30 ms 1192 KB Output is correct
64 Correct 27 ms 1192 KB Output is correct
65 Correct 49 ms 1192 KB Output is correct
66 Correct 72 ms 1192 KB Output is correct
67 Correct 99 ms 1192 KB Output is correct
68 Correct 104 ms 1192 KB Output is correct
69 Correct 92 ms 1192 KB Output is correct