I got it working at the competition, but when I entered it, it was rejected on the premise that it took to long to return a result.
Here is my original program
Here is the revised version.
This is the third and current version.
To run, you may want to place this file, dollars.txt, in the same directory.
I'm not going to post the source, as it's really space-consuming. It's available via links provided. I think right click+ save as will be most efficient.
I ran it on my computer. Small values work fine. Arbitrarily I chose $55.75 as a test value. It completed in 3:57 (min:sec), returning a correct value of 1004770130.
I set to work revising it. My first revision eliminates the total(int) call in each loop. Rather, it uses an int that is updated before and after each nested for loop.
This version completes in 2:07, correctly again. Still way too long.
SO, I changed the arrays of values to individual ints.
It runs correctly, and takes 1:27.
I don't believe this is fast enough, but do not know where to move. I thought there would be some sort of combination/permutation algorithm to give me instantaneous results, but have not been able to come up with it.
Even a more efficient counting method escapes me. For example, every time .20 is part of a combination, I can also count a combination with 2 .10's, one with 2 .05's and a .10, and one with 4 .05's. I know this could work, but nothing clicks as far as implementation, especially when counting beyond a simple denomination.
SO, codemasters, my challenge to you is to help me optimize the program to run better. My goal is under 5 seconds, if possible. However, I believe that a counting principle such as outlined above can run in real time. Oh, and if possible, if you supply code, if you provide reasons for the code as well.
Thank you thank you thank you.
