Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
造福后人#include<iostream> #include <string> #include<queue> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int n, k, t, dp[300005] ; struct Node{ int t,values,with; bool operator < (const Node &no)const { return t < no.t; } }ans[110]; int main() { freopen("D:\\in.txt","r",stdin); // freopen("D:\\out.txt","w",stdout); while(scanf("%d %d %d", &n, &k, &t) != EOF) { memset(ans, 0, sizeof(ans)); for(int i=1; i<=n; i++) dp[i]= -1; dp[0] = 0; for(int i=1; i<=n; i++) scanf("%d", &ans[i].t); for(int i=1; i<=n; i++) scanf("%d", &ans[i].values); for(int i=1; i<=n; i++) scanf("%d", &ans[i].with); sort(ans+1, ans+n+1); int ma = 0;//第一处WA,如果结果是0,ma=-1会WA for(int i=1; i<=n; i++) { for(int j=0; j<i; j++) { if(abs(ans[j].t - ans[i].t) >= abs(ans[j].with - ans[i].with) && dp[j] != -1)//第二处WA是否j状态能取到 { dp[i] = max(dp[i], dp[j] + ans[i].values); } } if(dp[i] > ma) ma = dp[i]; } cout<<ma<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator