标签:des blog http io ar os sp for strong
Description
Input
Output
Sample Input
2 2 100 1 100 2 3 1 10 1 11 100 12
Sample Output
330 1344
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<queue> #include<vector> #include<set> using namespace std; int t,n,a[102],p[102],sum[102],ans[102]; int main() { scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); memset(p,0,sizeof(p)); memset(sum,0,sizeof(sum)); memset(ans,0,sizeof(ans)); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%d",&a[i],&p[i]); sum[i]=sum[i-1]+a[i]; ans[i]=(sum[i]+10)*p[i]; } for(int i=1;i<=n;i++) for(int j=1;j<=i;j++) { ans[i]=min(ans[i],(sum[i]-sum[j]+10)*p[i]+ans[j]); } printf("%d\n",ans[n]); } }
标签:des blog http io ar os sp for strong
原文地址:http://www.cnblogs.com/a972290869/p/4101849.html