답안 #489708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
489708 2021-11-24T02:47:58 Z mdn2002 Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 16096 KB
#include<bits/stdc++.h>
using namespace std;
int n , a , b , y [2003] , dp [2003][2003];
long long mask;
bool f ( int x , int num )
{
    if ( x == n )
    {
        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;
}
bool ck ( )
{
    memset ( dp , -1 , sizeof dp );
    return f ( 0 , 0 );
}
int main()
{
    //freopen ( "fence8.in" , "r" , stdin );
    //freopen ( "fence8.out" , "w" , stdout );
    scanf ( "%d%d%d" , &n , &a , &b );
    for ( int i = 0 ; i < n ; i ++ ) scanf ( "%d" , &y [i] );
    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:32:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf ( "%d%d%d" , &n , &a , &b );
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:33:44: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     for ( int i = 0 ; i < n ; i ++ ) scanf ( "%d" , &y [i] );
      |                                      ~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 15980 KB Output is correct
2 Correct 94 ms 15948 KB Output is correct
3 Correct 91 ms 15972 KB Output is correct
4 Correct 99 ms 15976 KB Output is correct
5 Correct 97 ms 15976 KB Output is correct
6 Correct 93 ms 15972 KB Output is correct
7 Correct 92 ms 15980 KB Output is correct
8 Correct 98 ms 15972 KB Output is correct
9 Correct 92 ms 15948 KB Output is correct
10 Correct 99 ms 16080 KB Output is correct
11 Correct 102 ms 15948 KB Output is correct
12 Correct 95 ms 15948 KB Output is correct
13 Correct 93 ms 15980 KB Output is correct
14 Correct 94 ms 15948 KB Output is correct
15 Correct 92 ms 15980 KB Output is correct
16 Correct 95 ms 15976 KB Output is correct
17 Correct 92 ms 15980 KB Output is correct
18 Correct 91 ms 15912 KB Output is correct
19 Correct 96 ms 15972 KB Output is correct
20 Correct 93 ms 15976 KB Output is correct
21 Correct 94 ms 15948 KB Output is correct
22 Correct 94 ms 15976 KB Output is correct
23 Correct 91 ms 15948 KB Output is correct
24 Correct 100 ms 15972 KB Output is correct
25 Correct 95 ms 15976 KB Output is correct
26 Correct 102 ms 15972 KB Output is correct
27 Correct 95 ms 15948 KB Output is correct
28 Correct 93 ms 15984 KB Output is correct
29 Correct 91 ms 15948 KB Output is correct
30 Correct 101 ms 15976 KB Output is correct
31 Correct 93 ms 15948 KB Output is correct
32 Correct 98 ms 15948 KB Output is correct
33 Correct 92 ms 15976 KB Output is correct
34 Correct 93 ms 15980 KB Output is correct
35 Correct 95 ms 15976 KB Output is correct
36 Correct 96 ms 15984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 15948 KB Output is correct
2 Correct 92 ms 15976 KB Output is correct
3 Correct 92 ms 15948 KB Output is correct
4 Correct 94 ms 15948 KB Output is correct
5 Correct 99 ms 15980 KB Output is correct
6 Correct 95 ms 15976 KB Output is correct
7 Correct 93 ms 15948 KB Output is correct
8 Correct 97 ms 15948 KB Output is correct
9 Correct 96 ms 15932 KB Output is correct
10 Correct 92 ms 15976 KB Output is correct
11 Correct 103 ms 15980 KB Output is correct
12 Correct 94 ms 15972 KB Output is correct
13 Correct 95 ms 15948 KB Output is correct
14 Correct 94 ms 15948 KB Output is correct
15 Correct 94 ms 15976 KB Output is correct
16 Correct 98 ms 15976 KB Output is correct
17 Correct 96 ms 15976 KB Output is correct
18 Correct 93 ms 15980 KB Output is correct
19 Correct 92 ms 15972 KB Output is correct
20 Correct 98 ms 15948 KB Output is correct
21 Correct 96 ms 15972 KB Output is correct
22 Correct 94 ms 15948 KB Output is correct
23 Correct 98 ms 15948 KB Output is correct
24 Correct 92 ms 15948 KB Output is correct
25 Correct 93 ms 15980 KB Output is correct
26 Correct 94 ms 15972 KB Output is correct
27 Correct 99 ms 16068 KB Output is correct
28 Correct 95 ms 15980 KB Output is correct
29 Correct 104 ms 15948 KB Output is correct
30 Correct 106 ms 15948 KB Output is correct
31 Correct 97 ms 15972 KB Output is correct
32 Correct 102 ms 15976 KB Output is correct
33 Correct 100 ms 15948 KB Output is correct
34 Correct 98 ms 15988 KB Output is correct
35 Correct 100 ms 15976 KB Output is correct
36 Correct 96 ms 15948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 15976 KB Output is correct
2 Correct 100 ms 15976 KB Output is correct
3 Correct 94 ms 15948 KB Output is correct
4 Correct 93 ms 15948 KB Output is correct
5 Correct 94 ms 15972 KB Output is correct
6 Correct 93 ms 15908 KB Output is correct
7 Correct 101 ms 15976 KB Output is correct
8 Correct 96 ms 15976 KB Output is correct
9 Correct 94 ms 15972 KB Output is correct
10 Correct 92 ms 15948 KB Output is correct
11 Correct 107 ms 15972 KB Output is correct
12 Correct 95 ms 15972 KB Output is correct
13 Correct 93 ms 15976 KB Output is correct
14 Correct 93 ms 15948 KB Output is correct
15 Correct 107 ms 15948 KB Output is correct
16 Correct 95 ms 15980 KB Output is correct
17 Correct 97 ms 15980 KB Output is correct
18 Correct 96 ms 15976 KB Output is correct
19 Correct 98 ms 15984 KB Output is correct
20 Correct 96 ms 15948 KB Output is correct
21 Correct 98 ms 15948 KB Output is correct
22 Correct 101 ms 15948 KB Output is correct
23 Correct 97 ms 15980 KB Output is correct
24 Correct 108 ms 15868 KB Output is correct
25 Correct 100 ms 15900 KB Output is correct
26 Correct 109 ms 15948 KB Output is correct
27 Correct 127 ms 16076 KB Output is correct
28 Correct 124 ms 15976 KB Output is correct
29 Correct 124 ms 15976 KB Output is correct
30 Correct 142 ms 15980 KB Output is correct
31 Correct 126 ms 15976 KB Output is correct
32 Correct 125 ms 15980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 103 ms 15976 KB Output is correct
2 Correct 94 ms 15972 KB Output is correct
3 Correct 93 ms 15948 KB Output is correct
4 Correct 91 ms 15948 KB Output is correct
5 Correct 97 ms 15976 KB Output is correct
6 Correct 95 ms 15948 KB Output is correct
7 Correct 95 ms 15972 KB Output is correct
8 Correct 92 ms 15976 KB Output is correct
9 Correct 94 ms 15980 KB Output is correct
10 Correct 93 ms 15976 KB Output is correct
11 Correct 92 ms 15948 KB Output is correct
12 Correct 92 ms 15948 KB Output is correct
13 Correct 91 ms 15976 KB Output is correct
14 Correct 97 ms 15972 KB Output is correct
15 Correct 96 ms 15972 KB Output is correct
16 Correct 92 ms 15976 KB Output is correct
17 Correct 91 ms 15948 KB Output is correct
18 Correct 102 ms 15972 KB Output is correct
19 Correct 103 ms 15948 KB Output is correct
20 Correct 91 ms 15972 KB Output is correct
21 Correct 92 ms 15980 KB Output is correct
22 Correct 92 ms 15948 KB Output is correct
23 Correct 94 ms 15976 KB Output is correct
24 Correct 96 ms 15976 KB Output is correct
25 Correct 98 ms 15976 KB Output is correct
26 Correct 92 ms 15984 KB Output is correct
27 Correct 91 ms 15948 KB Output is correct
28 Correct 91 ms 15976 KB Output is correct
29 Correct 92 ms 15980 KB Output is correct
30 Correct 93 ms 15948 KB Output is correct
31 Correct 94 ms 15976 KB Output is correct
32 Correct 91 ms 15968 KB Output is correct
33 Correct 91 ms 15976 KB Output is correct
34 Correct 92 ms 15948 KB Output is correct
35 Correct 94 ms 15972 KB Output is correct
36 Correct 90 ms 15948 KB Output is correct
37 Correct 94 ms 16068 KB Output is correct
38 Correct 92 ms 15892 KB Output is correct
39 Correct 103 ms 15976 KB Output is correct
40 Correct 95 ms 15972 KB Output is correct
41 Correct 95 ms 15948 KB Output is correct
42 Correct 98 ms 15988 KB Output is correct
43 Correct 96 ms 15948 KB Output is correct
44 Correct 96 ms 16076 KB Output is correct
45 Correct 96 ms 15976 KB Output is correct
46 Correct 99 ms 15948 KB Output is correct
47 Correct 98 ms 15980 KB Output is correct
48 Correct 101 ms 15976 KB Output is correct
49 Correct 111 ms 15948 KB Output is correct
50 Correct 115 ms 15976 KB Output is correct
51 Correct 127 ms 15948 KB Output is correct
52 Correct 132 ms 15996 KB Output is correct
53 Correct 129 ms 15980 KB Output is correct
54 Correct 124 ms 15976 KB Output is correct
55 Correct 125 ms 15948 KB Output is correct
56 Correct 97 ms 15976 KB Output is correct
57 Correct 108 ms 15948 KB Output is correct
58 Correct 103 ms 15948 KB Output is correct
59 Correct 107 ms 15984 KB Output is correct
60 Correct 113 ms 15976 KB Output is correct
61 Correct 109 ms 15948 KB Output is correct
62 Correct 110 ms 15976 KB Output is correct
63 Correct 107 ms 15976 KB Output is correct
64 Correct 119 ms 15976 KB Output is correct
65 Correct 94 ms 15948 KB Output is correct
66 Correct 99 ms 15980 KB Output is correct
67 Correct 102 ms 15976 KB Output is correct
68 Correct 106 ms 15976 KB Output is correct
69 Correct 108 ms 15976 KB Output is correct
70 Correct 104 ms 15948 KB Output is correct
71 Correct 121 ms 15980 KB Output is correct
72 Correct 112 ms 15976 KB Output is correct
73 Correct 106 ms 15948 KB Output is correct
74 Correct 107 ms 15980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 15976 KB Output is correct
2 Correct 94 ms 15948 KB Output is correct
3 Correct 94 ms 15948 KB Output is correct
4 Correct 93 ms 15948 KB Output is correct
5 Correct 92 ms 16096 KB Output is correct
6 Correct 91 ms 15924 KB Output is correct
7 Correct 92 ms 16068 KB Output is correct
8 Correct 94 ms 15976 KB Output is correct
9 Correct 95 ms 15976 KB Output is correct
10 Correct 94 ms 15948 KB Output is correct
11 Correct 93 ms 15948 KB Output is correct
12 Correct 92 ms 15980 KB Output is correct
13 Correct 91 ms 16004 KB Output is correct
14 Correct 92 ms 15948 KB Output is correct
15 Correct 106 ms 15948 KB Output is correct
16 Correct 104 ms 15976 KB Output is correct
17 Correct 92 ms 15976 KB Output is correct
18 Correct 94 ms 15980 KB Output is correct
19 Correct 96 ms 15972 KB Output is correct
20 Correct 91 ms 15948 KB Output is correct
21 Correct 93 ms 15972 KB Output is correct
22 Correct 91 ms 15980 KB Output is correct
23 Correct 101 ms 15948 KB Output is correct
24 Correct 98 ms 15948 KB Output is correct
25 Correct 94 ms 15976 KB Output is correct
26 Correct 93 ms 15948 KB Output is correct
27 Correct 99 ms 15976 KB Output is correct
28 Correct 96 ms 15976 KB Output is correct
29 Correct 98 ms 15976 KB Output is correct
30 Correct 96 ms 15972 KB Output is correct
31 Correct 94 ms 15948 KB Output is correct
32 Correct 94 ms 15976 KB Output is correct
33 Correct 95 ms 15948 KB Output is correct
34 Correct 95 ms 15976 KB Output is correct
35 Correct 103 ms 15980 KB Output is correct
36 Correct 105 ms 15980 KB Output is correct
37 Correct 115 ms 15988 KB Output is correct
38 Correct 122 ms 15948 KB Output is correct
39 Correct 122 ms 15980 KB Output is correct
40 Correct 131 ms 15976 KB Output is correct
41 Correct 130 ms 15948 KB Output is correct
42 Correct 129 ms 15948 KB Output is correct
43 Correct 94 ms 15968 KB Output is correct
44 Correct 98 ms 15948 KB Output is correct
45 Correct 104 ms 15980 KB Output is correct
46 Correct 106 ms 15948 KB Output is correct
47 Correct 104 ms 15948 KB Output is correct
48 Correct 107 ms 15948 KB Output is correct
49 Correct 107 ms 15976 KB Output is correct
50 Correct 109 ms 15992 KB Output is correct
51 Correct 105 ms 15976 KB Output is correct
52 Execution timed out 1087 ms 15992 KB Time limit exceeded
53 Halted 0 ms 0 KB -