-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11566-1.cpp
50 lines (46 loc) · 1.39 KB
/
11566-1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,x,t,k,lim,CC,pLIM;
int favour[ 105 ], cost[ 105 ];
int dp[ 105 ][ 1200 ][ 24 ];
int buy( int tea, int f , int llevo )
{
if( tea == k )
return 0;
if( dp[ tea ][ f ][ llevo ] != -1 )
return dp[ tea ][ f ][ llevo ];
int n0,n1,n2;
n0 = buy( tea + 1 , f , llevo );
n1 = ceil((f+(cost[tea])+CC)*0.1)+(f+(cost[tea])) <= lim && llevo+1 < pLIM? buy( tea + 1 , f + (cost[tea]) , llevo + 1) + favour[ tea ] : 0;
n2 = ceil((f+(cost[tea]*2+CC))*0.1)+(f+(cost[tea])*2) <= lim && llevo+2 < pLIM ? buy( tea + 1 , f + (cost[tea]*2) , llevo + 2 ) + favour[ tea ] * 2 : 0;
// cout << tea << " " << f << " " << llevo << " " << max( n0 , max( n1 , n2 ) ) << endl;
return dp[ tea ][ f ][ llevo ] = max( n0 , max( n1 , n2 ) );
}
int main()
{
int sum = 0 ;
while( scanf("%d %d %d %d",&n,&x,&t,&k) , (n||x||t||k) )
{
for( int i = 0 ; i < k ; ++i )
{
scanf("%d",&cost[i]);
favour[ i ] = 0 ;
for( int j = 0 ; j < n + 1 ; ++j )
{
scanf( "%d" , &sum );
favour[ i ] += sum;
}
}
lim = ((n+1)*x)-((n+1)*t);
CC = ((n+1)*t);
pLIM = (n+1)*2;
// cout << lim << endl;
memset( dp , -1 , sizeof dp );
// cout << buy( 0 , 0 , 0 ) << " " << n+1 << endl;
printf( "%.2lf\n", (double)buy(0, 0, 0 )/(double)(n+1) );
}
return 0;
}