Submission #489713

# Submission time Handle Problem Language Result Execution time Memory
489713 2021-11-24T03:18:51 Z mdn2002 Bali Sculptures (APIO15_sculpture) C++14
71 / 100
137 ms 16104 KB
#include<bits/stdc++.h>
using namespace std;
int n , a , b , y [2003] , dp [2003][2003] , dpp [2003] , pre [2003];
long long mask;
bool f ( int x , int num )
{
    if ( x == n + 1 )
    {
        if ( a <= num && num <= b ) return 1;
        return 0;
    }
    if ( dp [x][num] != -1 ) return dp [x][num];
    bool ans = 0;
    long long sum = 0;
    for ( int i = x ; i <= n ; i ++ )
    {
        sum += y [i];
        if ( ( mask | sum ) > mask ) continue;
        ans = max ( ans , f ( i + 1 , num + 1 ) );
    }
    return dp [x][num] = ans;
}
long long ff ( )
{
    for ( int i = 1 ; i <= n ; i ++ ) dpp [i] = 1e8;
    for ( int i = 1 ; i <= n ; i ++ )
    {
        for ( int j = 1 ; j <= i ; j ++ )
        {
            long long sum = pre [i] - pre [ j - 1 ];
            if ( ( mask | sum ) > mask ) continue;
            dpp [i] = min ( dpp [i] , dpp [ j - 1 ] + 1 );
        }
    }
    return dpp [n];
}
bool ck ( )
{
    memset ( dp , -1 , sizeof dp );
    if ( n <= 100 ) return f ( 1 , 0 );
    else
    {
        int mn = ff ( );
        return ( mn <= b );
    }
}
int main()
{
    //freopen ( "fence8.in" , "r" , stdin );
    //freopen ( "fence8.out" , "w" , stdout );
    scanf ( "%d%d%d" , &n , &a , &b );
    for ( int i = 1 ; i <= n ; i ++ )
    {
        scanf ( "%d" , &y [i] );
        pre [i] = y [i] + pre [ i - 1 ];
    }
    mask = ( 1ll << 50 ) - 1;
    for ( int i = 49 ; i >= 0 ; i -- )
    {
        mask ^= ( 1ll << i );
        if ( ck ( ) == 0 ) mask ^= ( 1ll << i );
    }
    printf ( "%lld" , mask );
}

Compilation message

sculpture.cpp: In function 'bool f(int, int)':
sculpture.cpp:21:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   21 |     return dp [x][num] = ans;
      |            ~~~~~~~~~~~~^~~~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:51:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     scanf ( "%d%d%d" , &n , &a , &b );
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:54:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         scanf ( "%d" , &y [i] );
      |         ~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 94 ms 15992 KB Output is correct
2 Correct 94 ms 15980 KB Output is correct
3 Correct 93 ms 15980 KB Output is correct
4 Correct 97 ms 15980 KB Output is correct
5 Correct 97 ms 15936 KB Output is correct
6 Correct 93 ms 15980 KB Output is correct
7 Correct 94 ms 15948 KB Output is correct
8 Correct 104 ms 15976 KB Output is correct
9 Correct 96 ms 15948 KB Output is correct
10 Correct 93 ms 15976 KB Output is correct
11 Correct 92 ms 15980 KB Output is correct
12 Correct 104 ms 15988 KB Output is correct
13 Correct 98 ms 15992 KB Output is correct
14 Correct 92 ms 15984 KB Output is correct
15 Correct 92 ms 15948 KB Output is correct
16 Correct 93 ms 15980 KB Output is correct
17 Correct 97 ms 15948 KB Output is correct
18 Correct 93 ms 15980 KB Output is correct
19 Correct 92 ms 15948 KB Output is correct
20 Correct 96 ms 15980 KB Output is correct
21 Correct 92 ms 15984 KB Output is correct
22 Correct 99 ms 15976 KB Output is correct
23 Correct 93 ms 15948 KB Output is correct
24 Correct 94 ms 15980 KB Output is correct
25 Correct 103 ms 15948 KB Output is correct
26 Correct 95 ms 15980 KB Output is correct
27 Correct 93 ms 16060 KB Output is correct
28 Correct 92 ms 15980 KB Output is correct
29 Correct 92 ms 15980 KB Output is correct
30 Correct 94 ms 15872 KB Output is correct
31 Correct 93 ms 15948 KB Output is correct
32 Correct 92 ms 15980 KB Output is correct
33 Correct 94 ms 15992 KB Output is correct
34 Correct 94 ms 15976 KB Output is correct
35 Correct 92 ms 15884 KB Output is correct
36 Correct 93 ms 15980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 16104 KB Output is correct
2 Correct 96 ms 15948 KB Output is correct
3 Correct 97 ms 15948 KB Output is correct
4 Correct 96 ms 15980 KB Output is correct
5 Correct 95 ms 15980 KB Output is correct
6 Correct 101 ms 15976 KB Output is correct
7 Correct 94 ms 15948 KB Output is correct
8 Correct 96 ms 15948 KB Output is correct
9 Correct 94 ms 15976 KB Output is correct
10 Correct 93 ms 15976 KB Output is correct
11 Correct 94 ms 16068 KB Output is correct
12 Correct 94 ms 15976 KB Output is correct
13 Correct 94 ms 16068 KB Output is correct
14 Correct 98 ms 15948 KB Output is correct
15 Correct 93 ms 15980 KB Output is correct
16 Correct 93 ms 15948 KB Output is correct
17 Correct 97 ms 15976 KB Output is correct
18 Correct 95 ms 15948 KB Output is correct
19 Correct 92 ms 15948 KB Output is correct
20 Correct 95 ms 15980 KB Output is correct
21 Correct 93 ms 15980 KB Output is correct
22 Correct 94 ms 15980 KB Output is correct
23 Correct 102 ms 15976 KB Output is correct
24 Correct 95 ms 15980 KB Output is correct
25 Correct 94 ms 15948 KB Output is correct
26 Correct 95 ms 15904 KB Output is correct
27 Correct 97 ms 15992 KB Output is correct
28 Correct 93 ms 15948 KB Output is correct
29 Correct 99 ms 15980 KB Output is correct
30 Correct 94 ms 15980 KB Output is correct
31 Correct 97 ms 15972 KB Output is correct
32 Correct 99 ms 15948 KB Output is correct
33 Correct 105 ms 15980 KB Output is correct
34 Correct 100 ms 15948 KB Output is correct
35 Correct 97 ms 15948 KB Output is correct
36 Correct 97 ms 15948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 15976 KB Output is correct
2 Correct 93 ms 15944 KB Output is correct
3 Correct 93 ms 15948 KB Output is correct
4 Correct 98 ms 15948 KB Output is correct
5 Correct 102 ms 15980 KB Output is correct
6 Correct 95 ms 15996 KB Output is correct
7 Correct 93 ms 15948 KB Output is correct
8 Correct 93 ms 15948 KB Output is correct
9 Correct 93 ms 15980 KB Output is correct
10 Correct 97 ms 15984 KB Output is correct
11 Correct 94 ms 15984 KB Output is correct
12 Correct 100 ms 15980 KB Output is correct
13 Correct 93 ms 15948 KB Output is correct
14 Correct 96 ms 15980 KB Output is correct
15 Correct 102 ms 15948 KB Output is correct
16 Correct 97 ms 15976 KB Output is correct
17 Correct 104 ms 15984 KB Output is correct
18 Correct 100 ms 15976 KB Output is correct
19 Correct 96 ms 15984 KB Output is correct
20 Correct 103 ms 15980 KB Output is correct
21 Correct 108 ms 15948 KB Output is correct
22 Correct 105 ms 15984 KB Output is correct
23 Correct 103 ms 15976 KB Output is correct
24 Correct 95 ms 15948 KB Output is correct
25 Correct 102 ms 15976 KB Output is correct
26 Correct 110 ms 15980 KB Output is correct
27 Correct 122 ms 15980 KB Output is correct
28 Correct 127 ms 16068 KB Output is correct
29 Correct 137 ms 15980 KB Output is correct
30 Correct 131 ms 15980 KB Output is correct
31 Correct 134 ms 15984 KB Output is correct
32 Correct 123 ms 15948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 15948 KB Output is correct
2 Correct 92 ms 15948 KB Output is correct
3 Correct 96 ms 15976 KB Output is correct
4 Correct 94 ms 15980 KB Output is correct
5 Correct 92 ms 15948 KB Output is correct
6 Correct 93 ms 15980 KB Output is correct
7 Correct 92 ms 15980 KB Output is correct
8 Correct 93 ms 15948 KB Output is correct
9 Correct 93 ms 15980 KB Output is correct
10 Correct 97 ms 16100 KB Output is correct
11 Correct 92 ms 15984 KB Output is correct
12 Correct 94 ms 15984 KB Output is correct
13 Correct 96 ms 15948 KB Output is correct
14 Correct 100 ms 15980 KB Output is correct
15 Correct 94 ms 15980 KB Output is correct
16 Correct 93 ms 15948 KB Output is correct
17 Correct 98 ms 15980 KB Output is correct
18 Correct 94 ms 15980 KB Output is correct
19 Correct 97 ms 15948 KB Output is correct
20 Correct 96 ms 15980 KB Output is correct
21 Correct 97 ms 15980 KB Output is correct
22 Correct 95 ms 15948 KB Output is correct
23 Correct 101 ms 15948 KB Output is correct
24 Correct 92 ms 15948 KB Output is correct
25 Correct 92 ms 15948 KB Output is correct
26 Correct 99 ms 15980 KB Output is correct
27 Correct 95 ms 15988 KB Output is correct
28 Correct 102 ms 15976 KB Output is correct
29 Correct 93 ms 15948 KB Output is correct
30 Correct 98 ms 15976 KB Output is correct
31 Correct 99 ms 15984 KB Output is correct
32 Correct 97 ms 15948 KB Output is correct
33 Correct 96 ms 15976 KB Output is correct
34 Correct 92 ms 15980 KB Output is correct
35 Correct 92 ms 15948 KB Output is correct
36 Correct 94 ms 15948 KB Output is correct
37 Correct 96 ms 15980 KB Output is correct
38 Correct 94 ms 15980 KB Output is correct
39 Correct 94 ms 15984 KB Output is correct
40 Correct 96 ms 15976 KB Output is correct
41 Correct 97 ms 15948 KB Output is correct
42 Correct 101 ms 15992 KB Output is correct
43 Correct 101 ms 15984 KB Output is correct
44 Correct 97 ms 15948 KB Output is correct
45 Correct 99 ms 15948 KB Output is correct
46 Correct 96 ms 15980 KB Output is correct
47 Correct 100 ms 15948 KB Output is correct
48 Correct 105 ms 15976 KB Output is correct
49 Correct 123 ms 15996 KB Output is correct
50 Correct 116 ms 15948 KB Output is correct
51 Correct 126 ms 15980 KB Output is correct
52 Correct 125 ms 15948 KB Output is correct
53 Correct 125 ms 15948 KB Output is correct
54 Correct 132 ms 15948 KB Output is correct
55 Correct 126 ms 15948 KB Output is correct
56 Correct 94 ms 15980 KB Output is correct
57 Correct 106 ms 15980 KB Output is correct
58 Correct 104 ms 15948 KB Output is correct
59 Correct 105 ms 15948 KB Output is correct
60 Correct 107 ms 15948 KB Output is correct
61 Correct 109 ms 15948 KB Output is correct
62 Correct 114 ms 16068 KB Output is correct
63 Correct 111 ms 15948 KB Output is correct
64 Correct 119 ms 15984 KB Output is correct
65 Correct 96 ms 15992 KB Output is correct
66 Correct 97 ms 15976 KB Output is correct
67 Correct 106 ms 15984 KB Output is correct
68 Correct 103 ms 15980 KB Output is correct
69 Correct 114 ms 15984 KB Output is correct
70 Correct 104 ms 15948 KB Output is correct
71 Correct 111 ms 15988 KB Output is correct
72 Correct 110 ms 15984 KB Output is correct
73 Correct 108 ms 15984 KB Output is correct
74 Correct 117 ms 15948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 15948 KB Output is correct
2 Correct 92 ms 15976 KB Output is correct
3 Correct 98 ms 15948 KB Output is correct
4 Correct 92 ms 15980 KB Output is correct
5 Correct 99 ms 15948 KB Output is correct
6 Correct 94 ms 15948 KB Output is correct
7 Correct 92 ms 15980 KB Output is correct
8 Correct 97 ms 15992 KB Output is correct
9 Correct 102 ms 15948 KB Output is correct
10 Correct 93 ms 15948 KB Output is correct
11 Correct 92 ms 15920 KB Output is correct
12 Correct 96 ms 15948 KB Output is correct
13 Correct 94 ms 15984 KB Output is correct
14 Correct 92 ms 15984 KB Output is correct
15 Correct 92 ms 15948 KB Output is correct
16 Correct 93 ms 15976 KB Output is correct
17 Correct 94 ms 15980 KB Output is correct
18 Correct 92 ms 15980 KB Output is correct
19 Correct 95 ms 15952 KB Output is correct
20 Correct 93 ms 15948 KB Output is correct
21 Correct 96 ms 15948 KB Output is correct
22 Correct 93 ms 15980 KB Output is correct
23 Correct 93 ms 15948 KB Output is correct
24 Correct 96 ms 15988 KB Output is correct
25 Correct 95 ms 15980 KB Output is correct
26 Correct 95 ms 15980 KB Output is correct
27 Correct 95 ms 15948 KB Output is correct
28 Correct 97 ms 15976 KB Output is correct
29 Correct 95 ms 15980 KB Output is correct
30 Correct 106 ms 15948 KB Output is correct
31 Correct 99 ms 15984 KB Output is correct
32 Correct 98 ms 15976 KB Output is correct
33 Correct 97 ms 15948 KB Output is correct
34 Correct 97 ms 15980 KB Output is correct
35 Correct 104 ms 15996 KB Output is correct
36 Correct 107 ms 15948 KB Output is correct
37 Correct 120 ms 15948 KB Output is correct
38 Correct 124 ms 15948 KB Output is correct
39 Correct 127 ms 15984 KB Output is correct
40 Correct 127 ms 15948 KB Output is correct
41 Correct 124 ms 15948 KB Output is correct
42 Correct 125 ms 15984 KB Output is correct
43 Correct 96 ms 15948 KB Output is correct
44 Correct 100 ms 15976 KB Output is correct
45 Correct 105 ms 15948 KB Output is correct
46 Correct 111 ms 15988 KB Output is correct
47 Correct 110 ms 15948 KB Output is correct
48 Correct 108 ms 15984 KB Output is correct
49 Correct 107 ms 15984 KB Output is correct
50 Correct 108 ms 15980 KB Output is correct
51 Incorrect 93 ms 15948 KB Output isn't correct
52 Halted 0 ms 0 KB -