Gorosort is equally easy, but only after you do the math.
For gorosort you get E(n) = N. Hence ans is just the number of out-of-place
elements.

On Mon, May 9, 2011 at 1:00 PM, kumar anurag <anurag.it.jo...@gmail.com>wrote:

> GoroSort , i think was tougher, after seeing the number of people solved ,
> i even didi not read the problem statement...
>
> Woking code for Candy Splitting is below, u can check it for both Small and
> Large tests, it passes all
>
> ----------------------------------------------------------
> #include <stdio.h>
> #include<stdlib.h>
> #include<iostream>
> #include<set>
> #include<vector>
> #include<algorithm>
> using namespace std;
>
> int main()
> {
>         FILE *p=fopen("input.in","r");
>         FILE *p2=fopen("output.txt","w");
>
>         int cases;
>         //cin>>cases;
>         fscanf(p,"%d",&cases);
>         int cs=0;
>         while(cases--)
>         {
>
>           //cin>>N;
>           int N;
>           fscanf(p,"%d",&N);
>
>           int total_sum=0,xors=0;
>           int array[N+1];
>          //main work starts here...
>           for(int i=0;i<N;i++)
>           {
>             fscanf(p,"%d",&array[i]);
>             total_sum+=array[i];
>             xors^=array[i];
>           }
>
>          sort(array,array+N);
>
>          if(xors!=0)
>              fprintf(p2,"Case #%d: NO\n",++cs);
>          else
>              fprintf(p2,"Case #%d: %d\n",++cs,total_sum-array[0]);
>
>        }//while
>
>    fclose(p);
>    fclose(p2);
>
>     return 0;
> }
>
> ---------------------
>
>
>
>
>
>
>
> On Mon, May 9, 2011 at 12:01 PM, Abioy Sun <abioy....@gmail.com> wrote:
>
>> And the last one, GoroSort?
>>
>>
>> 2011/5/9 kumar anurag <anurag.it.jo...@gmail.com>
>>
>>> find xor of all elements - if its equal to zeo then Case has solution
>>> otherwise NO
>>> for finding the soltuion just sort all the elements and find the (sum of
>>> all -sum of smallest)..
>>>
>>>
>>>
>>> On Sun, May 8, 2011 at 9:50 PM, Kunal Patil <kp101...@gmail.com> wrote:
>>>
>>>> Can anybody tell me How to solve candy splitting problem appeared in
>>>> Google Code Jam Qualification round?
>>>> I know there is solution, if XOR of all elements comes to be zero.
>>>> But i wasn't able to proceed from there as I couldn't think of way how
>>>> to partition that elements.
>>>> (I have read solutions from other contestants but as expected they are
>>>> dirty for the one who doesn't know logic behind program)
>>>> So plz help...
>>>>
>>>> --
>>>> 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.
>>>>
>>>
>>>
>>>
>>> --
>>> Kumar Anurag
>>>
>>>  --
>>> 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.
>>
>
>
>
> --
> Kumar Anurag
>
> --
> 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.

Reply via email to