Hi, Any solution other than brute force(exponential growth) for this problem ?
On Sun, Mar 6, 2011 at 6:42 PM, UTKARSH SRIVASTAV <usrivastav...@gmail.com>wrote: > can anyone please tell me why i am getting wrong answer for > problem.....https://www.spoj.pl/problems/TRT/ > . > . > . > MY CODE IS THIS AND TO BE TESTED IN gcc COMPILER > > > #include<stdio.h> > double a[2100]; > double fun(long long int m,long long int n,double count) > { > double k,l; > count++; > if(m==n) > { > > return count*a[m]; > } > if((k=(fun(m+1,n,count)))>(l=(fun(m,n-1,count)))) > { > > return (count*a[m]+k); > } > else > { > > > return (count*a[n]+l); > } > } > int main() > { > long long int i,m,n; > double ans,c=0; > scanf("%lld",&n); > for(i=1;i<=n;i++) > { > scanf("%lf",&a[i]); > } > m=1; > ans=fun(m,n,c); > printf("%.0lf\n",ans); > return 0; > } > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.