果的dp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int n, k, t;
int dp[110];
struct P
{
int times, value, fat;
}node[110];
int myabs(int a)
{
return a>0?a:-a;
}
int cmp( const void* a, const void* b )
{
return (*(P*)a).times-(*(P*)b).times;
}
int main()
{
while ( 3 == scanf("%d%d%d", &n, &k, &t) )
{
int i, j, max= 0;
for ( i = 1 ; i <= n ; i++ )
scanf("%d", &node[i].times);
for ( i = 1 ; i <= n ; i++ )
scanf("%d", &node[i].value);
for ( i = 1 ; i <= n ; i++ )
scanf("%d", &node[i].fat);
qsort(node+1, n, sizeof(P), cmp);
node[0].value= node[0].fat= node[0].times= 0;
memset(dp, -1, sizeof(dp));
dp[0]= 0;
for ( i = 1 ; i <= n ; i++ )
{
for ( j = 0 ; j < i ; j++ )
if ( myabs(node[i].times-node[j].times) >= myabs(node[i].fat-node[j].fat) && dp[i] < dp[j] )
dp[i]= dp[j];
if ( dp[i] != -1 )
dp[i]+=node[i].value;
if ( max < dp[i] )
max= dp[i];
}
printf("%d\n", max);
}
return 0;
}