标签:
5
1
1 3
3 2
4 3
2 3
1 4
153
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; int n,s,t[10005],f[10005],sumt[10005],sumf[10005],dp[10005]; int main(){ cin>>n>>s; for(int i = 1;i <= n;i++){ scanf("%d%d",&t[i],&f[i]); sumt[i] = sumt[i-1] + t[i]; sumf[i] = sumf[i-1] + f[i]; dp[i] = 987654321; } for(int i = 1;i <= n;i++){ for(int j = i;j >= 1;j--){ dp[i] = min(dp[i],dp[j-1] + (s + sumt[i] - sumt[j-1]) * (sumf[n] - sumf[j-1])); } } cout<<dp[n]; return 0; }
标签:
原文地址:http://www.cnblogs.com/hyfer/p/5791411.html