易错点:
- f[i]=min(f[j]+任务批(j~i)的总价格(sumT[i]*(sumC[i]-sumC[j]))+无限远点的弧光灯(启动费用*(sumT[n]-sumT[j])).
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int MAXN=5200;
int f[MAXN],sumT[MAXN],sumC[MAXN];
int main(){
memset(f,0x3f,sizeof(f));
int n,s;
scanf("%d%d",&n,&s);
for(int i=1;i<=n;i++){
int t,c;
scanf("%d%d",&t,&c);
sumT[i]=sumT[i-1]+t;
sumC[i]=sumC[i-1]+c;
}
f[0]=0;
for(int i=1;i<=n;i++){
for(int j=0;j<i;j++){
f[i]=min(f[i],f[j]
+sumT[i]*(sumC[i]-sumC[j])
+s*(sumC[n]-sumC[j])
);
}
}
printf("%d\n",f[n]);
return 0;
}