Solutions:
A:
Solution Notes: If there were no coupon, this problem would be solved by "greedily" using gifts
in increasing order of P+S values (since we want to pack in as many gifts as possible before we
hit the budget). In fact, if we know the gift to
Solutions:
A:
Solution Notes: We can calculate K by taking the total number of hay bales and dividing by N.
Now that we know the target height K of each pile, let X be the total number of hay bales sitting
at height above K. Each one of these hay bales mu
Solutions:
A:
Solution Notes: This problem is not too hard if we make the observation that 17N = 16N + N,
and in binary 16N is just the binary representation of N followed by four digits of 0 (that is, N
shifted right by four digits). We therefore add the
Solutions:
A:
Solution Notes: Perhaps the easiest way to solve this problem is to first sort the knot locations
and then build an array of differences between successive locations. For example, the locations
of 0, 2, 4, 6, and 10 in the sample input would
Solutions:
A:
Solution Notes: This problem can be solved by "brute force", by simply trying to remove each
possible cow ID from the line, checking after each one whether it gives the best answer (the
longest consecutive block of equal cow IDs). Below is T
Solutions:
A:
Solution Notes: We solve this problem by "brute force". Since we need to change direction
exactly once at each cow (many students seem to have overlooked this condition!) it suffices to
enumerate all possible N! permutations of cows. For eac