链接:点击打开链接
题意:给出一个长度是n的区间中每一个元素的颜色,每次只能选一个区间染色,染色的代价为这个区间不同颜色数的平方,问最小代价
代码:
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;
const long long INF=0x3f3f3f3f3f3f3f3f;
long long a[100005],dp[100005];
long long pre[100005],nex[100005];
int main(){ //dp[i]表示到第i位的最小花费
long long n,i,j,tmp; //也就知道状态转移方程为,
while(scanf("%I64d",&n)!=EOF){ //dp[i]=