#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 1200000000
const int maxn = 5003;
const int maxk = 1670;
int d[maxn][2][maxk],v[maxn],n;
bool vis[maxn][2][maxk];
int dp(int i,int j,int k){
if(vis[i][j][k]) return d[i][j][k];
vis[i][j][k] = true;
if(k==0) return d[i][j][k]=0;
int& ans=d[i][j][k];
ans=dp(i+2,1,k-1)+(v[i+1]-v[i+2])*(v[i+1]-v[i+2]);
if(n-i-1>=k*3) ans=min(an......
阅读全文