My team's solution to the Qualification Round problem.
A - example: 10
B - should be easy: 176,877
C - no hurry: 15,541,379
D - metropolis: 7,307,087
E - high bonus: 21,465,945
Total: 44,491,298
Due to different data inputs and distributions we decided to adapt the algorithm for different use cases which in turn let us solve B, C and E fairly efficiently. A used a randomized solution for fun.
This MS Visual Studio solution uses 3 different source files for different data variations.
To compile any of the three source files in the solution you'll have to comment out the other two.