【动态规划】bzoj1663 [Usaco2006 Open]赶集
http://blog.csdn.net/u011265346/article/details/44906469
#include<cstdio> #include<algorithm> using namespace std; #define N 401 struct Point{int p,v;}a[N]; bool operator < (const Point &a,const Point &b){return a.v<b.v;} int n,map[N][N],f[N]; int main() { // freopen("bzoj1663.in","r",stdin); scanf("%d",&n); for(int i=1;i<=n;++i) { scanf("%d",&a[i].v); a[i].p=i; } sort(a+1,a+n+1); for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) scanf("%d",&map[i][j]); for(int i=1;i<=n;++i) if(map[1][a[i].p]<=a[i].v) f[i]=1; for(int i=1;i<=n;++i) for(int j=1;j<i;++j) if(a[j].v+map[a[j].p][a[i].p]<=a[i].v) f[i]=max(f[i],f[j]+1); printf("%d\n",*max_element(f+1,f+1+n)); return 0; }
——The Solution By AutSky_JadeK From UESTC
转载请注明出处:http://www.cnblogs.com/autsky-jadek/