It took me a long time to come up this counter-example.

1
6
6
1 1 1
1 2 1
1 3 1
3 4 0 5 0 6 1
4 1 0 2 0 3 0 4 1
4 1 0 2 0 3 0 5 1

Your solution decided that it is IMPOSSIBLE.

However, the correct solution is
1 1 1 1 1 1 (all malted)

Xiongqi

Fork Security <[email protected]>于2015年11月26日周四 下午12:06写道:

> Hello,
>
> I'm trying solve the Milkshake problem[0] from Round 1A of the CodeJam,
> 2008.
>
> I have a list of costumers' preferences and I need to produce a set of
> batches
> of milkshakes, specifying for each batch if I have to order them malted or
> unmalted -- to satisfy all the clients.
>
> Moreover, I have to minimize the number of malted batches.
>
> My idea was to build a list of lists, where each list represents the set of
> preferences for a costumer.
>
>     preferences = [
>         [(1,1), (2, 0)], ## That is, flavour1 malted, flavour2 unmalted
>         ...
>     ]
>
> Then I sort the entire list of preferences by the length of each set of
> preferences, then sorted again for each set of preferences,
> putting the unmalted flavours first, then the malted one.
>
>     preferences = [
>         [(1,1)],
>         [(1,0), (3,0)],
>         [(5,0), (1,1), (3,1)],
>         ...
>     ]
>
> By satisfying the costumers, starting from the most "choosey", trying their
> "unmalted preferences" first, I thought I was supposed to pick (whenever
> possible) the batches that satisfied each costumer, keeping the number of
> malted batches the lowest possibile.
>
> Why I'm wrong?
>
> The code that I'm using to generate the solution is here[1].
>
> Thank you in advance!
>
> [0], https://code.google.com/codejam/contest/32016/dashboard#s=p1
> [1], https://gist.github.com/giuscri/50046796166ef9fcb0ae
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/72288e08-6b39-4a18-ae06-6418edf5ee9f%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAGDEU-%2ByPOD5CtePAOHPdtBMsEPZcjUFjN6C8BS_p%2BDVauGyjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to