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

WA,WA,WA.....

Posted by lxp_rs at 2006-08-07 00:23:33 on Problem 1062
#include "stdio.h"

const int MAX=110;
int MIN;
int m;

struct qq
{
     int num;
     int price;  
}dd[MAX][MAX];
int pp[MAX],ll[MAX],xx[MAX];

int  fun(int p,int l,int x,struct qq *d)
{
     int min=0;
     int xp;
     for(int k=1;k<=x;k++)
     {
          if(l-ll[d[k].num]<=m)
          {
              xp=d[k].price+fun(pp[d[k].num],ll[d[k].num],xx[d[k].num],dd[d[k].num]);
          }
          else xp=p;
          if(min>xp) min=xp;
     }
     return min;
}

int main()
{
    int n,i,j;
    while(2==scanf("%d%d",&m,&n))
    {
           for(i=1;i<=n;i++)
           {
               scanf("%d%d%d",&pp[i],&ll[i],&xx[i]);
               for(j=1;j<=xx[i];j++)
                    scanf("%d%d",&dd[i][j].num,&dd[i][j].price);                     
           }
           MIN=fun(pp[1],ll[1],xx[1],dd[1]);
           printf("%d\n",MIN);                
    }
    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