//#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];
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 );
}
/*
4 1 4
2 3 1 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31624 KB |
Output is correct |
2 |
Correct |
13 ms |
31700 KB |
Output is correct |
3 |
Correct |
13 ms |
31668 KB |
Output is correct |
4 |
Correct |
14 ms |
31744 KB |
Output is correct |
5 |
Correct |
13 ms |
31688 KB |
Output is correct |
6 |
Correct |
14 ms |
31684 KB |
Output is correct |
7 |
Correct |
14 ms |
31692 KB |
Output is correct |
8 |
Correct |
21 ms |
31692 KB |
Output is correct |
9 |
Correct |
18 ms |
31700 KB |
Output is correct |
10 |
Correct |
19 ms |
31688 KB |
Output is correct |
11 |
Correct |
18 ms |
31692 KB |
Output is correct |
12 |
Correct |
18 ms |
31652 KB |
Output is correct |
13 |
Correct |
18 ms |
31704 KB |
Output is correct |
14 |
Correct |
12 ms |
31692 KB |
Output is correct |
15 |
Correct |
13 ms |
31592 KB |
Output is correct |
16 |
Correct |
14 ms |
31584 KB |
Output is correct |
17 |
Correct |
13 ms |
31692 KB |
Output is correct |
18 |
Correct |
17 ms |
31692 KB |
Output is correct |
19 |
Correct |
14 ms |
31692 KB |
Output is correct |
20 |
Correct |
15 ms |
31676 KB |
Output is correct |
21 |
Incorrect |
19 ms |
31640 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 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 |
16 ms |
31640 KB |
Output is correct |
5 |
Correct |
13 ms |
31600 KB |
Output is correct |
6 |
Correct |
13 ms |
31580 KB |
Output is correct |
7 |
Correct |
13 ms |
31692 KB |
Output is correct |
8 |
Correct |
19 ms |
31692 KB |
Output is correct |
9 |
Correct |
26 ms |
31672 KB |
Output is correct |
10 |
Correct |
18 ms |
31696 KB |
Output is correct |
11 |
Correct |
18 ms |
31696 KB |
Output is correct |
12 |
Correct |
18 ms |
31688 KB |
Output is correct |
13 |
Correct |
20 ms |
31688 KB |
Output is correct |
14 |
Correct |
13 ms |
31680 KB |
Output is correct |
15 |
Correct |
12 ms |
31692 KB |
Output is correct |
16 |
Correct |
14 ms |
31660 KB |
Output is correct |
17 |
Correct |
13 ms |
31600 KB |
Output is correct |
18 |
Correct |
13 ms |
31692 KB |
Output is correct |
19 |
Correct |
13 ms |
31700 KB |
Output is correct |
20 |
Correct |
14 ms |
31652 KB |
Output is correct |
21 |
Incorrect |
18 ms |
31596 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
31596 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 |
12 ms |
31692 KB |
Output is correct |
6 |
Correct |
14 ms |
31624 KB |
Output is correct |
7 |
Correct |
14 ms |
31696 KB |
Output is correct |
8 |
Correct |
19 ms |
31664 KB |
Output is correct |
9 |
Correct |
18 ms |
31680 KB |
Output is correct |
10 |
Correct |
19 ms |
31652 KB |
Output is correct |
11 |
Correct |
19 ms |
31644 KB |
Output is correct |
12 |
Correct |
19 ms |
31708 KB |
Output is correct |
13 |
Correct |
19 ms |
31696 KB |
Output is correct |
14 |
Correct |
24 ms |
31692 KB |
Output is correct |
15 |
Correct |
193 ms |
31620 KB |
Output is correct |
16 |
Execution timed out |
1090 ms |
31660 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31628 KB |
Output is correct |
2 |
Correct |
12 ms |
31636 KB |
Output is correct |
3 |
Correct |
13 ms |
31692 KB |
Output is correct |
4 |
Correct |
13 ms |
31576 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 |
31636 KB |
Output is correct |
8 |
Correct |
21 ms |
31696 KB |
Output is correct |
9 |
Correct |
18 ms |
31692 KB |
Output is correct |
10 |
Correct |
19 ms |
31692 KB |
Output is correct |
11 |
Correct |
24 ms |
31796 KB |
Output is correct |
12 |
Correct |
18 ms |
31656 KB |
Output is correct |
13 |
Correct |
18 ms |
31700 KB |
Output is correct |
14 |
Correct |
12 ms |
31592 KB |
Output is correct |
15 |
Correct |
12 ms |
31692 KB |
Output is correct |
16 |
Correct |
13 ms |
31632 KB |
Output is correct |
17 |
Correct |
13 ms |
31616 KB |
Output is correct |
18 |
Correct |
13 ms |
31692 KB |
Output is correct |
19 |
Correct |
13 ms |
31600 KB |
Output is correct |
20 |
Correct |
14 ms |
31656 KB |
Output is correct |
21 |
Incorrect |
19 ms |
31700 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
31692 KB |
Output is correct |
2 |
Correct |
13 ms |
31676 KB |
Output is correct |
3 |
Correct |
14 ms |
31676 KB |
Output is correct |
4 |
Correct |
13 ms |
31692 KB |
Output is correct |
5 |
Correct |
13 ms |
31636 KB |
Output is correct |
6 |
Correct |
14 ms |
31620 KB |
Output is correct |
7 |
Correct |
13 ms |
31692 KB |
Output is correct |
8 |
Correct |
19 ms |
31696 KB |
Output is correct |
9 |
Correct |
17 ms |
31596 KB |
Output is correct |
10 |
Correct |
19 ms |
31696 KB |
Output is correct |
11 |
Correct |
21 ms |
31696 KB |
Output is correct |
12 |
Correct |
25 ms |
31696 KB |
Output is correct |
13 |
Correct |
18 ms |
31700 KB |
Output is correct |
14 |
Correct |
17 ms |
31692 KB |
Output is correct |
15 |
Correct |
13 ms |
31684 KB |
Output is correct |
16 |
Correct |
14 ms |
31692 KB |
Output is correct |
17 |
Correct |
15 ms |
31696 KB |
Output is correct |
18 |
Incorrect |
19 ms |
31696 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |