답안 #489694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
489694 2021-11-24T01:33:23 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 ( 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31692 KB Output is correct
2 Correct 13 ms 31584 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 31696 KB Output is correct
6 Correct 13 ms 31820 KB Output is correct
7 Correct 13 ms 31692 KB Output is correct
8 Correct 17 ms 31624 KB Output is correct
9 Correct 17 ms 31692 KB Output is correct
10 Correct 17 ms 31612 KB Output is correct
11 Correct 17 ms 31692 KB Output is correct
12 Correct 18 ms 31584 KB Output is correct
13 Correct 17 ms 31620 KB Output is correct
14 Correct 14 ms 31692 KB Output is correct
15 Correct 13 ms 31580 KB Output is correct
16 Correct 14 ms 31656 KB Output is correct
17 Correct 13 ms 31676 KB Output is correct
18 Correct 14 ms 31692 KB Output is correct
19 Correct 14 ms 31620 KB Output is correct
20 Correct 14 ms 31584 KB Output is correct
21 Correct 17 ms 31692 KB Output is correct
22 Correct 17 ms 31664 KB Output is correct
23 Correct 17 ms 31692 KB Output is correct
24 Correct 19 ms 31604 KB Output is correct
25 Correct 19 ms 31692 KB Output is correct
26 Correct 18 ms 31680 KB Output is correct
27 Correct 14 ms 31692 KB Output is correct
28 Correct 13 ms 31584 KB Output is correct
29 Correct 13 ms 31620 KB Output is correct
30 Correct 15 ms 31692 KB Output is correct
31 Correct 18 ms 31708 KB Output is correct
32 Correct 18 ms 31640 KB Output is correct
33 Correct 19 ms 31596 KB Output is correct
34 Correct 18 ms 31704 KB Output is correct
35 Correct 17 ms 31692 KB Output is correct
36 Correct 17 ms 31688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 31692 KB Output is correct
2 Correct 14 ms 31692 KB Output is correct
3 Correct 13 ms 31676 KB Output is correct
4 Correct 14 ms 31740 KB Output is correct
5 Correct 13 ms 31584 KB Output is correct
6 Correct 13 ms 31692 KB Output is correct
7 Correct 13 ms 31588 KB Output is correct
8 Correct 17 ms 31696 KB Output is correct
9 Correct 17 ms 31696 KB Output is correct
10 Correct 18 ms 31692 KB Output is correct
11 Correct 18 ms 31692 KB Output is correct
12 Correct 18 ms 31692 KB Output is correct
13 Correct 17 ms 31696 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 31632 KB Output is correct
18 Correct 15 ms 31632 KB Output is correct
19 Correct 15 ms 31696 KB Output is correct
20 Correct 14 ms 31676 KB Output is correct
21 Correct 17 ms 31692 KB Output is correct
22 Correct 18 ms 31692 KB Output is correct
23 Correct 17 ms 31692 KB Output is correct
24 Correct 18 ms 31696 KB Output is correct
25 Correct 17 ms 31692 KB Output is correct
26 Correct 18 ms 31692 KB Output is correct
27 Correct 20 ms 31692 KB Output is correct
28 Correct 147 ms 31692 KB Output is correct
29 Execution timed out 1096 ms 31692 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31692 KB Output is correct
2 Correct 13 ms 31640 KB Output is correct
3 Correct 14 ms 31592 KB Output is correct
4 Correct 16 ms 31692 KB Output is correct
5 Correct 15 ms 31584 KB Output is correct
6 Correct 13 ms 31596 KB Output is correct
7 Correct 14 ms 31656 KB Output is correct
8 Correct 17 ms 31592 KB Output is correct
9 Correct 18 ms 31572 KB Output is correct
10 Correct 17 ms 31680 KB Output is correct
11 Correct 17 ms 31692 KB Output is correct
12 Correct 17 ms 31696 KB Output is correct
13 Correct 16 ms 31676 KB Output is correct
14 Correct 21 ms 31680 KB Output is correct
15 Correct 148 ms 31680 KB Output is correct
16 Execution timed out 1090 ms 31692 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31692 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 31680 KB Output is correct
5 Correct 13 ms 31692 KB Output is correct
6 Correct 13 ms 31680 KB Output is correct
7 Correct 14 ms 31592 KB Output is correct
8 Correct 18 ms 31692 KB Output is correct
9 Correct 18 ms 31636 KB Output is correct
10 Correct 17 ms 31568 KB Output is correct
11 Correct 17 ms 31692 KB Output is correct
12 Correct 18 ms 31668 KB Output is correct
13 Correct 17 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 14 ms 31688 KB Output is correct
17 Correct 16 ms 31692 KB Output is correct
18 Correct 13 ms 31656 KB Output is correct
19 Correct 13 ms 31600 KB Output is correct
20 Correct 14 ms 31616 KB Output is correct
21 Correct 18 ms 31692 KB Output is correct
22 Correct 18 ms 31704 KB Output is correct
23 Correct 20 ms 31708 KB Output is correct
24 Correct 18 ms 31692 KB Output is correct
25 Correct 17 ms 31708 KB Output is correct
26 Correct 21 ms 31704 KB Output is correct
27 Correct 14 ms 31696 KB Output is correct
28 Correct 14 ms 31664 KB Output is correct
29 Correct 13 ms 31692 KB Output is correct
30 Correct 15 ms 31692 KB Output is correct
31 Correct 17 ms 31692 KB Output is correct
32 Correct 17 ms 31692 KB Output is correct
33 Correct 18 ms 31708 KB Output is correct
34 Correct 17 ms 31692 KB Output is correct
35 Correct 17 ms 31704 KB Output is correct
36 Correct 17 ms 31704 KB Output is correct
37 Correct 24 ms 31584 KB Output is correct
38 Correct 146 ms 31692 KB Output is correct
39 Execution timed out 1062 ms 31692 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31692 KB Output is correct
2 Correct 12 ms 31584 KB Output is correct
3 Correct 13 ms 31692 KB Output is correct
4 Correct 13 ms 31640 KB Output is correct
5 Correct 14 ms 31644 KB Output is correct
6 Correct 14 ms 31692 KB Output is correct
7 Correct 14 ms 31628 KB Output is correct
8 Correct 18 ms 31608 KB Output is correct
9 Correct 18 ms 31648 KB Output is correct
10 Correct 17 ms 31692 KB Output is correct
11 Correct 19 ms 31624 KB Output is correct
12 Correct 19 ms 31692 KB Output is correct
13 Correct 17 ms 31696 KB Output is correct
14 Correct 13 ms 31692 KB Output is correct
15 Correct 15 ms 31668 KB Output is correct
16 Correct 13 ms 31692 KB Output is correct
17 Correct 15 ms 31696 KB Output is correct
18 Correct 18 ms 31652 KB Output is correct
19 Correct 18 ms 31788 KB Output is correct
20 Correct 18 ms 31692 KB Output is correct
21 Correct 17 ms 31620 KB Output is correct
22 Correct 19 ms 31724 KB Output is correct
23 Correct 19 ms 31616 KB Output is correct
24 Correct 21 ms 31700 KB Output is correct
25 Correct 145 ms 31596 KB Output is correct
26 Execution timed out 1096 ms 31692 KB Time limit exceeded
27 Halted 0 ms 0 KB -