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 |
WA,WA,WA.....#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator