Submission #489696

# Submission time Handle Problem Language Result Execution time Memory
489696 2021-11-24T01:35:29 Z mdn2002 Bali Sculptures (APIO15_sculpture) C++14
46 / 100
21 ms 31732 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
long long n , a , b , y [2003] , dp [2003][2003] , ans = 1e16;
long long f ( int x , int num )
{
    if ( x == n && a <= num && num <= b ) return 0;
    if ( x == n ) return 1e16;
    if ( dp [x][num] != -1 ) return dp [x][num];
    long long ans = 1e16 , sum = 0;
    for ( int i = x ; i < n ; i ++ )
    {
        sum += y [i];
        ans = min ( ans , ( f ( i + 1 , num + 1 ) | sum ) );
    }
    return dp [x][num] = ans;
}

void ff ( int x , int num , long long sum , long long tmp )
{
    if ( num > b ) return;
    if ( x == n && a <= num && num <= b )
    {
        ans = min ( ans , ( tmp | sum ) );
        return;
    }
    if ( x == n ) return;

    ff ( x + 1 , num + 1 , 0 , ( tmp | ( sum + y [x] ) ) );
    if ( x + 1 != n ) ff ( x + 1 , num , sum + y [x] , tmp );
}
int main()
{
    //freopen ( "fence8.in" , "r" , stdin );
    //freopen ( "fence8.out" , "w" , stdout );
    memset ( dp , -1 , sizeof dp );
    cin >> n >> a >> b;
    for ( int i = 0 ; i < n ; i ++ ) cin >> y [i];
    if ( n <= 20 )
    {
        ff ( 0 , 0 , 0 , 0 );
        cout << ans << endl;
    }
    else cout << f ( 0 , 0 );
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31664 KB Output is correct
2 Correct 13 ms 31656 KB Output is correct
3 Correct 13 ms 31628 KB Output is correct
4 Correct 14 ms 31692 KB Output is correct
5 Correct 14 ms 31604 KB Output is correct
6 Correct 14 ms 31608 KB Output is correct
7 Correct 13 ms 31692 KB Output is correct
8 Correct 13 ms 31692 KB Output is correct
9 Correct 14 ms 31676 KB Output is correct
10 Correct 13 ms 31592 KB Output is correct
11 Correct 18 ms 31692 KB Output is correct
12 Correct 14 ms 31600 KB Output is correct
13 Correct 19 ms 31608 KB Output is correct
14 Correct 13 ms 31692 KB Output is correct
15 Correct 13 ms 31692 KB Output is correct
16 Correct 13 ms 31692 KB Output is correct
17 Correct 14 ms 31664 KB Output is correct
18 Correct 13 ms 31692 KB Output is correct
19 Correct 14 ms 31692 KB Output is correct
20 Correct 13 ms 31692 KB Output is correct
21 Correct 15 ms 31596 KB Output is correct
22 Correct 14 ms 31684 KB Output is correct
23 Correct 14 ms 31692 KB Output is correct
24 Correct 13 ms 31612 KB Output is correct
25 Correct 14 ms 31692 KB Output is correct
26 Correct 18 ms 31692 KB Output is correct
27 Correct 13 ms 31600 KB Output is correct
28 Correct 13 ms 31692 KB Output is correct
29 Correct 13 ms 31692 KB Output is correct
30 Correct 13 ms 31692 KB Output is correct
31 Correct 15 ms 31656 KB Output is correct
32 Correct 13 ms 31692 KB Output is correct
33 Correct 18 ms 31644 KB Output is correct
34 Correct 18 ms 31704 KB Output is correct
35 Correct 13 ms 31692 KB Output is correct
36 Correct 19 ms 31700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 31684 KB Output is correct
2 Correct 13 ms 31692 KB Output is correct
3 Correct 13 ms 31596 KB Output is correct
4 Correct 13 ms 31664 KB Output is correct
5 Correct 13 ms 31692 KB Output is correct
6 Correct 13 ms 31692 KB Output is correct
7 Correct 13 ms 31596 KB Output is correct
8 Correct 13 ms 31692 KB Output is correct
9 Correct 14 ms 31640 KB Output is correct
10 Correct 13 ms 31692 KB Output is correct
11 Correct 15 ms 31692 KB Output is correct
12 Correct 13 ms 31692 KB Output is correct
13 Correct 20 ms 31692 KB Output is correct
14 Correct 13 ms 31692 KB Output is correct
15 Correct 13 ms 31692 KB Output is correct
16 Correct 13 ms 31692 KB Output is correct
17 Correct 13 ms 31692 KB Output is correct
18 Correct 14 ms 31604 KB Output is correct
19 Correct 15 ms 31684 KB Output is correct
20 Correct 13 ms 31692 KB Output is correct
21 Correct 14 ms 31696 KB Output is correct
22 Correct 15 ms 31692 KB Output is correct
23 Correct 14 ms 31704 KB Output is correct
24 Correct 13 ms 31692 KB Output is correct
25 Correct 14 ms 31692 KB Output is correct
26 Correct 19 ms 31692 KB Output is correct
27 Correct 13 ms 31652 KB Output is correct
28 Correct 14 ms 31692 KB Output is correct
29 Correct 13 ms 31692 KB Output is correct
30 Correct 13 ms 31692 KB Output is correct
31 Correct 13 ms 31604 KB Output is correct
32 Correct 12 ms 31692 KB Output is correct
33 Correct 13 ms 31692 KB Output is correct
34 Correct 13 ms 31668 KB Output is correct
35 Correct 13 ms 31580 KB Output is correct
36 Correct 13 ms 31628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31692 KB Output is correct
2 Correct 13 ms 31692 KB Output is correct
3 Correct 13 ms 31692 KB Output is correct
4 Correct 13 ms 31692 KB Output is correct
5 Correct 13 ms 31692 KB Output is correct
6 Correct 13 ms 31648 KB Output is correct
7 Correct 13 ms 31616 KB Output is correct
8 Correct 14 ms 31692 KB Output is correct
9 Correct 13 ms 31612 KB Output is correct
10 Correct 14 ms 31692 KB Output is correct
11 Correct 13 ms 31600 KB Output is correct
12 Correct 13 ms 31604 KB Output is correct
13 Correct 19 ms 31692 KB Output is correct
14 Correct 13 ms 31616 KB Output is correct
15 Correct 13 ms 31692 KB Output is correct
16 Correct 18 ms 31600 KB Output is correct
17 Correct 13 ms 31644 KB Output is correct
18 Correct 13 ms 31700 KB Output is correct
19 Correct 13 ms 31692 KB Output is correct
20 Correct 13 ms 31692 KB Output is correct
21 Correct 13 ms 31688 KB Output is correct
22 Correct 13 ms 31692 KB Output is correct
23 Correct 13 ms 31660 KB Output is correct
24 Correct 13 ms 31692 KB Output is correct
25 Correct 13 ms 31684 KB Output is correct
26 Correct 14 ms 31692 KB Output is correct
27 Correct 13 ms 31692 KB Output is correct
28 Correct 14 ms 31692 KB Output is correct
29 Correct 14 ms 31680 KB Output is correct
30 Correct 14 ms 31692 KB Output is correct
31 Correct 14 ms 31676 KB Output is correct
32 Correct 14 ms 31692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31620 KB Output is correct
2 Correct 15 ms 31692 KB Output is correct
3 Correct 17 ms 31660 KB Output is correct
4 Correct 13 ms 31692 KB Output is correct
5 Correct 13 ms 31692 KB Output is correct
6 Correct 14 ms 31656 KB Output is correct
7 Correct 13 ms 31648 KB Output is correct
8 Correct 13 ms 31652 KB Output is correct
9 Correct 13 ms 31692 KB Output is correct
10 Correct 13 ms 31692 KB Output is correct
11 Correct 13 ms 31692 KB Output is correct
12 Correct 14 ms 31692 KB Output is correct
13 Correct 21 ms 31692 KB Output is correct
14 Correct 17 ms 31692 KB Output is correct
15 Correct 16 ms 31696 KB Output is correct
16 Correct 16 ms 31636 KB Output is correct
17 Correct 14 ms 31628 KB Output is correct
18 Correct 14 ms 31632 KB Output is correct
19 Correct 13 ms 31648 KB Output is correct
20 Correct 13 ms 31692 KB Output is correct
21 Correct 14 ms 31704 KB Output is correct
22 Correct 15 ms 31628 KB Output is correct
23 Correct 14 ms 31676 KB Output is correct
24 Correct 14 ms 31672 KB Output is correct
25 Correct 16 ms 31592 KB Output is correct
26 Correct 18 ms 31608 KB Output is correct
27 Correct 13 ms 31692 KB Output is correct
28 Correct 13 ms 31692 KB Output is correct
29 Correct 13 ms 31616 KB Output is correct
30 Correct 13 ms 31688 KB Output is correct
31 Correct 14 ms 31692 KB Output is correct
32 Correct 13 ms 31620 KB Output is correct
33 Correct 19 ms 31668 KB Output is correct
34 Correct 18 ms 31704 KB Output is correct
35 Correct 13 ms 31692 KB Output is correct
36 Correct 18 ms 31640 KB Output is correct
37 Correct 13 ms 31692 KB Output is correct
38 Correct 14 ms 31584 KB Output is correct
39 Correct 13 ms 31692 KB Output is correct
40 Correct 13 ms 31624 KB Output is correct
41 Correct 14 ms 31696 KB Output is correct
42 Correct 13 ms 31700 KB Output is correct
43 Correct 13 ms 31692 KB Output is correct
44 Correct 15 ms 31692 KB Output is correct
45 Correct 15 ms 31592 KB Output is correct
46 Correct 13 ms 31676 KB Output is correct
47 Correct 13 ms 31692 KB Output is correct
48 Correct 15 ms 31644 KB Output is correct
49 Correct 13 ms 31704 KB Output is correct
50 Correct 13 ms 31692 KB Output is correct
51 Correct 13 ms 31612 KB Output is correct
52 Correct 14 ms 31700 KB Output is correct
53 Correct 14 ms 31700 KB Output is correct
54 Correct 13 ms 31704 KB Output is correct
55 Correct 14 ms 31708 KB Output is correct
56 Incorrect 13 ms 31692 KB Output isn't correct
57 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 31732 KB Output is correct
2 Correct 12 ms 31692 KB Output is correct
3 Correct 13 ms 31692 KB Output is correct
4 Correct 13 ms 31632 KB Output is correct
5 Correct 17 ms 31692 KB Output is correct
6 Correct 17 ms 31692 KB Output is correct
7 Correct 13 ms 31692 KB Output is correct
8 Correct 13 ms 31576 KB Output is correct
9 Correct 13 ms 31692 KB Output is correct
10 Correct 13 ms 31640 KB Output is correct
11 Correct 13 ms 31664 KB Output is correct
12 Correct 13 ms 31668 KB Output is correct
13 Correct 18 ms 31660 KB Output is correct
14 Correct 14 ms 31692 KB Output is correct
15 Correct 13 ms 31700 KB Output is correct
16 Correct 14 ms 31704 KB Output is correct
17 Correct 13 ms 31584 KB Output is correct
18 Correct 15 ms 31700 KB Output is correct
19 Correct 13 ms 31640 KB Output is correct
20 Correct 18 ms 31692 KB Output is correct
21 Correct 18 ms 31676 KB Output is correct
22 Correct 13 ms 31620 KB Output is correct
23 Correct 18 ms 31696 KB Output is correct
24 Correct 15 ms 31692 KB Output is correct
25 Correct 13 ms 31636 KB Output is correct
26 Correct 14 ms 31692 KB Output is correct
27 Correct 13 ms 31656 KB Output is correct
28 Correct 13 ms 31696 KB Output is correct
29 Correct 13 ms 31672 KB Output is correct
30 Correct 13 ms 31660 KB Output is correct
31 Correct 14 ms 31632 KB Output is correct
32 Correct 13 ms 31704 KB Output is correct
33 Correct 14 ms 31692 KB Output is correct
34 Correct 13 ms 31708 KB Output is correct
35 Correct 13 ms 31700 KB Output is correct
36 Correct 13 ms 31592 KB Output is correct
37 Correct 13 ms 31692 KB Output is correct
38 Correct 14 ms 31692 KB Output is correct
39 Correct 14 ms 31704 KB Output is correct
40 Correct 14 ms 31692 KB Output is correct
41 Correct 14 ms 31600 KB Output is correct
42 Correct 17 ms 31656 KB Output is correct
43 Incorrect 15 ms 31628 KB Output isn't correct
44 Halted 0 ms 0 KB -