| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
0MS-G++#include <stdio.h>
const int L=101;
int v[L],c[L],f[L];
int t,n;
int main(void){
freopen ("1260.in","r",stdin);
freopen ("1260.out","w",stdout);
scanf ("%d",&t);
for (int p=1,sum;p<=t;p++){
scanf ("%d",&n);
for (int i=1;i<=n;i++)scanf ("%d%d",v+i,c+i);
f[0]=0,sum=0;
for (int i=1,pos;i<=n;i++){
sum+=v[i],pos=sum-v[1];
f[i]=(sum+10)*c[i];
for (int j=1,k;j<i;j++,pos-=v[j])
if ((k=f[j]+(pos+10)*c[i])<f[i])f[i]=k;
}
printf ("%d\n",f[n]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator