Submission #489695

# Submission time Handle Problem Language Result Execution time Memory
489695 2021-11-24T01:33:53 Z mdn2002 Bali Sculptures (APIO15_sculpture) C++14
9 / 100
1000 ms 31820 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];
    ff ( 0 , 0 , 0 , 0 );
    cout << ans;
}
# 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 12 ms 31692 KB Output is correct
4 Correct 12 ms 31692 KB Output is correct
5 Correct 13 ms 31600 KB Output is correct
6 Correct 13 ms 31692 KB Output is correct
7 Correct 13 ms 31692 KB Output is correct
8 Correct 13 ms 31648 KB Output is correct
9 Correct 13 ms 31692 KB Output is correct
10 Correct 13 ms 31624 KB Output is correct
11 Correct 13 ms 31584 KB Output is correct
12 Correct 13 ms 31692 KB Output is correct
13 Correct 21 ms 31624 KB Output is correct
14 Correct 13 ms 31692 KB Output is correct
15 Correct 12 ms 31640 KB Output is correct
16 Correct 13 ms 31668 KB Output is correct
17 Correct 13 ms 31692 KB Output is correct
18 Correct 13 ms 31636 KB Output is correct
19 Correct 14 ms 31692 KB Output is correct
20 Correct 13 ms 31668 KB Output is correct
21 Correct 14 ms 31692 KB Output is correct
22 Correct 14 ms 31680 KB Output is correct
23 Correct 14 ms 31632 KB Output is correct
24 Correct 13 ms 31692 KB Output is correct
25 Correct 14 ms 31612 KB Output is correct
26 Correct 18 ms 31692 KB Output is correct
27 Correct 13 ms 31680 KB Output is correct
28 Correct 14 ms 31588 KB Output is correct
29 Correct 13 ms 31692 KB Output is correct
30 Correct 13 ms 31624 KB Output is correct
31 Correct 14 ms 31692 KB Output is correct
32 Correct 14 ms 31820 KB Output is correct
33 Correct 19 ms 31692 KB Output is correct
34 Correct 20 ms 31692 KB Output is correct
35 Correct 16 ms 31604 KB Output is correct
36 Correct 18 ms 31692 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 15 ms 31684 KB Output is correct
4 Correct 13 ms 31672 KB Output is correct
5 Correct 14 ms 31692 KB Output is correct
6 Correct 13 ms 31660 KB Output is correct
7 Correct 13 ms 31664 KB Output is correct
8 Correct 13 ms 31636 KB Output is correct
9 Correct 14 ms 31692 KB Output is correct
10 Correct 13 ms 31676 KB Output is correct
11 Correct 13 ms 31692 KB Output is correct
12 Correct 14 ms 31600 KB Output is correct
13 Correct 21 ms 31700 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 31668 KB Output is correct
18 Correct 13 ms 31592 KB Output is correct
19 Correct 13 ms 31692 KB Output is correct
20 Correct 13 ms 31640 KB Output is correct
21 Correct 14 ms 31692 KB Output is correct
22 Correct 14 ms 31648 KB Output is correct
23 Correct 15 ms 31684 KB Output is correct
24 Correct 13 ms 31692 KB Output is correct
25 Correct 14 ms 31692 KB Output is correct
26 Correct 18 ms 31692 KB Output is correct
27 Correct 24 ms 31680 KB Output is correct
28 Correct 72 ms 31580 KB Output is correct
29 Correct 28 ms 31620 KB Output is correct
30 Execution timed out 1093 ms 31692 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31688 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 31648 KB Output is correct
6 Correct 13 ms 31640 KB Output is correct
7 Correct 13 ms 31664 KB Output is correct
8 Correct 13 ms 31692 KB Output is correct
9 Correct 13 ms 31664 KB Output is correct
10 Correct 13 ms 31692 KB Output is correct
11 Correct 13 ms 31584 KB Output is correct
12 Correct 16 ms 31648 KB Output is correct
13 Correct 18 ms 31692 KB Output is correct
14 Correct 25 ms 31692 KB Output is correct
15 Correct 71 ms 31692 KB Output is correct
16 Correct 27 ms 31692 KB Output is correct
17 Execution timed out 1090 ms 31692 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31628 KB Output is correct
2 Correct 13 ms 31652 KB Output is correct
3 Correct 13 ms 31580 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 31692 KB Output is correct
7 Correct 14 ms 31580 KB Output is correct
8 Correct 15 ms 31692 KB Output is correct
9 Correct 13 ms 31692 KB Output is correct
10 Correct 13 ms 31692 KB Output is correct
11 Correct 12 ms 31692 KB Output is correct
12 Correct 13 ms 31644 KB Output is correct
13 Correct 18 ms 31700 KB Output is correct
14 Correct 13 ms 31620 KB Output is correct
15 Correct 13 ms 31696 KB Output is correct
16 Correct 13 ms 31692 KB Output is correct
17 Correct 12 ms 31692 KB Output is correct
18 Correct 12 ms 31692 KB Output is correct
19 Correct 13 ms 31688 KB Output is correct
20 Correct 13 ms 31600 KB Output is correct
21 Correct 14 ms 31692 KB Output is correct
22 Correct 14 ms 31580 KB Output is correct
23 Correct 14 ms 31692 KB Output is correct
24 Correct 14 ms 31692 KB Output is correct
25 Correct 15 ms 31692 KB Output is correct
26 Correct 18 ms 31692 KB Output is correct
27 Correct 13 ms 31668 KB Output is correct
28 Correct 13 ms 31696 KB Output is correct
29 Correct 12 ms 31584 KB Output is correct
30 Correct 15 ms 31692 KB Output is correct
31 Correct 14 ms 31692 KB Output is correct
32 Correct 13 ms 31692 KB Output is correct
33 Correct 19 ms 31648 KB Output is correct
34 Correct 18 ms 31700 KB Output is correct
35 Correct 13 ms 31692 KB Output is correct
36 Correct 18 ms 31660 KB Output is correct
37 Correct 25 ms 31696 KB Output is correct
38 Correct 72 ms 31692 KB Output is correct
39 Correct 28 ms 31692 KB Output is correct
40 Execution timed out 1087 ms 31692 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31692 KB Output is correct
2 Correct 15 ms 31668 KB Output is correct
3 Correct 13 ms 31692 KB Output is correct
4 Correct 13 ms 31676 KB Output is correct
5 Correct 13 ms 31640 KB Output is correct
6 Correct 13 ms 31692 KB Output is correct
7 Correct 14 ms 31580 KB Output is correct
8 Correct 14 ms 31660 KB Output is correct
9 Correct 13 ms 31692 KB Output is correct
10 Correct 13 ms 31692 KB Output is correct
11 Correct 12 ms 31692 KB Output is correct
12 Correct 13 ms 31692 KB Output is correct
13 Correct 18 ms 31652 KB Output is correct
14 Correct 13 ms 31692 KB Output is correct
15 Correct 13 ms 31700 KB Output is correct
16 Correct 13 ms 31652 KB Output is correct
17 Correct 13 ms 31692 KB Output is correct
18 Correct 15 ms 31692 KB Output is correct
19 Correct 14 ms 31684 KB Output is correct
20 Correct 20 ms 31692 KB Output is correct
21 Correct 18 ms 31692 KB Output is correct
22 Correct 12 ms 31644 KB Output is correct
23 Correct 18 ms 31692 KB Output is correct
24 Correct 24 ms 31728 KB Output is correct
25 Correct 70 ms 31572 KB Output is correct
26 Correct 28 ms 31692 KB Output is correct
27 Execution timed out 1085 ms 31588 KB Time limit exceeded
28 Halted 0 ms 0 KB -