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 51 52 53 54 55 56
|
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <queue> #include <set> #include <vector> #define MID(x,y) ((x+y)>>1) #define iabs(x) ((x)>0?(x):-(x)) #define maxn 105 #define print() cout<<"-----"<<endl using namespace std;
struct node{ int t,p,s; bool operator < (const node &u) const{ return t < u.t; } }p[maxn]; int dp[maxn]; int main(){ int N, K, T; scanf("%d%d%d", &N, &K, &T); for(int i = 1;i <= N; ++i) scanf("%d", &p[i].t); for(int i = 1;i <= N; ++i) scanf("%d", &p[i].p); for(int i = 1;i <= N; ++i) scanf("%d", &p[i].s); sort(p+1,p+N+1); p[0].s = 0;p[0].t = 0;p[0].p = 0;
memset(dp,0,sizeof(dp)); int ans = 0; for (int i = 1; i <= N; ++i){ for (int j = i-1; j >= 0; --j){ if((dp[j] != 0 || j == 0) && iabs(p[j].s - p[i].s) <= p[i].t - p[j].t){ dp[i] = max(dp[i],dp[j] + p[i].p); } } ans = max(dp[i],ans); } printf("%dn", dp[N]); return 0; }
|