分析
考虑上一层还是上两层还是爬上去
AC代码
#includeusing namespace std;int f[1000005],a[1000005];int main() { int n; scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&a[i]); for (int i=1;i<=n;i++) f[i]=min(f[i-1]+a[i],min(f[i-2]+a[i-1],f[i-3]+a[i-2])); printf("%d\n",f[n]); return 0;}