Re: [algogeeks] Re: facebook programming question

2013-03-23 Thread rakesh kumar
@bharat n=4 k =2 1 2 5 7 this is the explanation for the 3rd case given in the question For the third case, group objects 1 and 2 together by moving the first object to position 2 and group objects 3 and 4 together by moving object 3 to position 7. Thus the answer is 1 + 2 = 3. here the eleme

Re: [algogeeks] Re: facebook programming question

2013-03-23 Thread bharat b
@rakesh : u misunderstood the question .. As per u'r ans to ex is ... 1,3 to 2 --> cost = 1+3=4 10 to 9 --> cost = 10. => total cost = 10+4 =14. On Sat, Mar 23, 2013 at 9:26 PM, rakesh kumar wrote: > > Ok here is a counter example for your solution > > for n= 5 ,k=2 > 1 2 3 9 10 > n-k=>3 so mov

Re: [algogeeks] Re: facebook programming question

2013-03-23 Thread rakesh kumar
Ok here is a counter example for your solution for n= 5 ,k=2 1 2 3 9 10 n-k=>3 so moving first 3 elements ans = 1+2+3 =6 but the answer should be 3 by placing center of 2 groups be 2,9 and moving 1 ,3 to 2 and 10 to 9 On Sat, Mar 23, 2013 at 9:09 PM, bharat b wrote: > If we take examples shown

Re: [algogeeks] Re: facebook programming question

2013-03-23 Thread bharat b
If we take examples shown above .. 3 3 1 1 3 --> we need 3 groups and 3 numbers are given.. no need to do anything. 3 2 1 2 4 --> we need to form 2 groups ..sort it. n-k=1-> first 1 element(s) has to be moved to other bigger elements. ans=1. 4 2 1 2 5 7 --> we need to form 2 groups.. sort it. n-k=2

Re: [algogeeks] Re: facebook programming question

2013-03-23 Thread rakesh kumar
I don't get it how sorting will get us to the solution On Sat, Mar 23, 2013 at 7:23 PM, bharat b wrote: > can any one give counter example where sorting doesn't work? > > > On Sat, Mar 23, 2013 at 3:15 PM, rakesh kumar > wrote: > >> this was a facebook online programming contest question so righ

Re: [algogeeks] Re: facebook programming question

2013-03-23 Thread bharat b
can any one give counter example where sorting doesn't work? On Sat, Mar 23, 2013 at 3:15 PM, rakesh kumar wrote: > this was a facebook online programming contest question so right now there > is no link available for that > > > On Sat, Mar 23, 2013 at 2:59 PM, Lucifer wrote: > >> Looks like a

[algogeeks] Brazilian online judge

2013-03-23 Thread Wladimir Tavares
http://www.urionlinejudge.com.br/judge/login Wladimir Araujo Tavares *Federal University of CearĂ¡ Homepage | Maratona| * -- You received this message because you are subscribed to th

Re: [algogeeks] Re: facebook programming question

2013-03-23 Thread rakesh kumar
this was a facebook online programming contest question so right now there is no link available for that On Sat, Mar 23, 2013 at 2:59 PM, Lucifer wrote: > Looks like a dp problem.. > I have an idea.. > I believe that u must have this problem hosted on a system having a code > checker.. > Can yo

[algogeeks] Re: facebook programming question

2013-03-23 Thread Lucifer
Looks like a dp problem.. I have an idea.. I believe that u must have this problem hosted on a system having a code checker.. Can you provide the link to the same, so that we can see if the logic works.. On Saturday, 23 March 2013 14:29:42 UTC+5:30, rakesh kumar wrote: > > > There are N objects

[algogeeks] Re: facebook programming question

2013-03-23 Thread rakesh kumar
> There are N objects kept in a row. The ith object is at position x_i. You > want to partition them into K groups. You want to move all objects > belonging to the same group to the same position. Objects in two different > groups may be placed at the same position. What is the minimum total amount