P2858 [USACO06FEB]奶牛零食Treats for the Cows

令f[i][j]表示正向选到第i个,倒向选到第j个点,

那么 f[i][j] = max(f[i – 1][j] + a[i] * (i + j),f[i][j – 1] + a[n – j + 1] * (i + j));

c++代码如下:

 

8 + 8 =