Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

0MS-G++

Posted by lz1 at 2010-09-20 20:20:22 on Problem 1260
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator