//#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 [102] , dp [2003][2003];
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;
}
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];
cout << f ( 0 , 0 );
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
31632 KB |
Output is correct |
2 |
Correct |
21 ms |
31696 KB |
Output is correct |
3 |
Correct |
18 ms |
31676 KB |
Output is correct |
4 |
Correct |
14 ms |
31696 KB |
Output is correct |
5 |
Correct |
15 ms |
31656 KB |
Output is correct |
6 |
Correct |
13 ms |
31708 KB |
Output is correct |
7 |
Correct |
19 ms |
31692 KB |
Output is correct |
8 |
Correct |
20 ms |
31668 KB |
Output is correct |
9 |
Correct |
17 ms |
31692 KB |
Output is correct |
10 |
Correct |
18 ms |
31696 KB |
Output is correct |
11 |
Correct |
16 ms |
31592 KB |
Output is correct |
12 |
Correct |
19 ms |
31704 KB |
Output is correct |
13 |
Correct |
15 ms |
31640 KB |
Output is correct |
14 |
Correct |
17 ms |
31700 KB |
Output is correct |
15 |
Correct |
22 ms |
31648 KB |
Output is correct |
16 |
Correct |
15 ms |
31692 KB |
Output is correct |
17 |
Correct |
13 ms |
31696 KB |
Output is correct |
18 |
Correct |
15 ms |
31600 KB |
Output is correct |
19 |
Correct |
16 ms |
31648 KB |
Output is correct |
20 |
Correct |
20 ms |
31692 KB |
Output is correct |
21 |
Incorrect |
24 ms |
31648 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
31576 KB |
Output is correct |
2 |
Correct |
16 ms |
31692 KB |
Output is correct |
3 |
Correct |
17 ms |
31592 KB |
Output is correct |
4 |
Correct |
19 ms |
31704 KB |
Output is correct |
5 |
Correct |
19 ms |
31584 KB |
Output is correct |
6 |
Correct |
15 ms |
31672 KB |
Output is correct |
7 |
Correct |
17 ms |
31608 KB |
Output is correct |
8 |
Correct |
14 ms |
31692 KB |
Output is correct |
9 |
Correct |
14 ms |
31700 KB |
Output is correct |
10 |
Correct |
14 ms |
31692 KB |
Output is correct |
11 |
Correct |
25 ms |
31696 KB |
Output is correct |
12 |
Correct |
23 ms |
31664 KB |
Output is correct |
13 |
Correct |
25 ms |
31688 KB |
Output is correct |
14 |
Correct |
14 ms |
31692 KB |
Output is correct |
15 |
Correct |
16 ms |
31700 KB |
Output is correct |
16 |
Correct |
14 ms |
31700 KB |
Output is correct |
17 |
Correct |
13 ms |
31692 KB |
Output is correct |
18 |
Correct |
24 ms |
31692 KB |
Output is correct |
19 |
Correct |
16 ms |
31660 KB |
Output is correct |
20 |
Correct |
18 ms |
31628 KB |
Output is correct |
21 |
Incorrect |
17 ms |
31644 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
31640 KB |
Output is correct |
2 |
Correct |
14 ms |
31624 KB |
Output is correct |
3 |
Correct |
15 ms |
31700 KB |
Output is correct |
4 |
Correct |
15 ms |
31704 KB |
Output is correct |
5 |
Correct |
17 ms |
31700 KB |
Output is correct |
6 |
Correct |
14 ms |
31692 KB |
Output is correct |
7 |
Correct |
18 ms |
31692 KB |
Output is correct |
8 |
Correct |
17 ms |
31692 KB |
Output is correct |
9 |
Correct |
15 ms |
31692 KB |
Output is correct |
10 |
Correct |
18 ms |
31704 KB |
Output is correct |
11 |
Correct |
21 ms |
31668 KB |
Output is correct |
12 |
Correct |
14 ms |
31692 KB |
Output is correct |
13 |
Correct |
14 ms |
31684 KB |
Output is correct |
14 |
Correct |
18 ms |
31620 KB |
Output is correct |
15 |
Correct |
13 ms |
31692 KB |
Output is correct |
16 |
Correct |
14 ms |
31692 KB |
Output is correct |
17 |
Correct |
15 ms |
31600 KB |
Output is correct |
18 |
Correct |
14 ms |
31692 KB |
Output is correct |
19 |
Correct |
14 ms |
31692 KB |
Output is correct |
20 |
Correct |
16 ms |
31636 KB |
Output is correct |
21 |
Correct |
17 ms |
31700 KB |
Output is correct |
22 |
Correct |
16 ms |
31648 KB |
Output is correct |
23 |
Correct |
14 ms |
31656 KB |
Output is correct |
24 |
Correct |
15 ms |
31680 KB |
Output is correct |
25 |
Correct |
17 ms |
31692 KB |
Output is correct |
26 |
Correct |
15 ms |
31676 KB |
Output is correct |
27 |
Correct |
14 ms |
31692 KB |
Output is correct |
28 |
Correct |
14 ms |
31692 KB |
Output is correct |
29 |
Correct |
15 ms |
31652 KB |
Output is correct |
30 |
Correct |
18 ms |
31676 KB |
Output is correct |
31 |
Correct |
16 ms |
31692 KB |
Output is correct |
32 |
Correct |
15 ms |
31692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
31632 KB |
Output is correct |
2 |
Correct |
17 ms |
31608 KB |
Output is correct |
3 |
Correct |
17 ms |
31692 KB |
Output is correct |
4 |
Correct |
18 ms |
31700 KB |
Output is correct |
5 |
Correct |
15 ms |
31704 KB |
Output is correct |
6 |
Correct |
14 ms |
31692 KB |
Output is correct |
7 |
Correct |
16 ms |
31692 KB |
Output is correct |
8 |
Correct |
25 ms |
31620 KB |
Output is correct |
9 |
Correct |
16 ms |
31692 KB |
Output is correct |
10 |
Correct |
14 ms |
31668 KB |
Output is correct |
11 |
Correct |
14 ms |
31660 KB |
Output is correct |
12 |
Correct |
15 ms |
31696 KB |
Output is correct |
13 |
Correct |
19 ms |
31688 KB |
Output is correct |
14 |
Correct |
16 ms |
31664 KB |
Output is correct |
15 |
Correct |
17 ms |
31696 KB |
Output is correct |
16 |
Correct |
17 ms |
31660 KB |
Output is correct |
17 |
Correct |
16 ms |
31692 KB |
Output is correct |
18 |
Correct |
15 ms |
31592 KB |
Output is correct |
19 |
Correct |
14 ms |
31684 KB |
Output is correct |
20 |
Correct |
16 ms |
31624 KB |
Output is correct |
21 |
Incorrect |
16 ms |
31700 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
31692 KB |
Output is correct |
2 |
Correct |
15 ms |
31628 KB |
Output is correct |
3 |
Correct |
14 ms |
31700 KB |
Output is correct |
4 |
Correct |
14 ms |
31704 KB |
Output is correct |
5 |
Correct |
17 ms |
31640 KB |
Output is correct |
6 |
Correct |
13 ms |
31692 KB |
Output is correct |
7 |
Correct |
15 ms |
31664 KB |
Output is correct |
8 |
Correct |
17 ms |
31632 KB |
Output is correct |
9 |
Correct |
19 ms |
31728 KB |
Output is correct |
10 |
Correct |
15 ms |
31684 KB |
Output is correct |
11 |
Correct |
14 ms |
31692 KB |
Output is correct |
12 |
Correct |
14 ms |
31644 KB |
Output is correct |
13 |
Correct |
16 ms |
31700 KB |
Output is correct |
14 |
Correct |
13 ms |
31692 KB |
Output is correct |
15 |
Correct |
13 ms |
31612 KB |
Output is correct |
16 |
Correct |
15 ms |
31592 KB |
Output is correct |
17 |
Correct |
13 ms |
31692 KB |
Output is correct |
18 |
Incorrect |
14 ms |
31692 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |