题目链接:http://noi.openjudge.cn/ch0206/9268/
题意:有N瓶酒,不能连续喝>=3瓶的酒,问能喝的最大的酒量。
f[i][j] 前 I 瓶中连续喝了 j 瓶的最大酒量
f[i][0] = f[i-1][3];
f[i][1,2] = f[i-1][j-1] + a[i];
#include <bits/stdc++.h>
using namespace std; int a[];
int f[][]; int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
for(int i=;i<=n;i++) {
f[i][] = f[i-][];
int maxx = f[i][];
for(int j=;j<=;j++) {
f[i][j] = f[i-][j-] + a[i];
maxx = max(maxx,f[i][j]);
}
f[i][] = maxx;
}
printf("%d\n",f[n][]); return ;
}