What's the problem in spoj? Wladimir Araujo Tavares *Federal University of CearĂ¡
* On Sat, Feb 12, 2011 at 3:00 PM, NEERAJ ARORA <neerdel...@gmail.com> wrote: > my code working for given test cases but it is giving WA. > > #include<iostream> > using namespace std; > struct party > { > float fun; > float money; > float ratio; > }p[100]; > int main() > { > party tmp; > float b,n; > while(1) > { > cin>>b>>n; > if(n==0&&b==0) > break; > for(int i=0;i<n;i++) > { > cin>>p[i].money>>p[i].fun; > p[i].ratio=p[i].fun/p[i].money; > } > for(int i=0;i<n-1;i++) > { > for(int j=i+1;j<n;j++) > { > if(p[i].ratio<p[j].ratio) > { > tmp=p[i]; > p[i]=p[j]; > p[j]=tmp; > } > } > } > for(int i=0;i<n;i++) > { > cout<<p[i].ratio<<endl; > } > float fun=0; > float sum=0; > for(int i=0;i<n;i++) > { > if(p[i].money+sum<=b) > { > sum=sum+p[i].money; > fun=fun+p[i].fun; > } > else > break; > > } > cout<<sum<<" "<<fun<<endl<<endl; > } > 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.