This was a rather easy problem, but somehow I made a mess out of it. I didn’t notice the third sample test case, and assumed that if at any point the reserve of a bank became negative, then it would not be possible to liquidate the debentures. But the third test case hints at the fact that, a bank’s reserve can be temporarily negative. If at the end of all processing, some bank’s reserve is still negative, then it can only mean that this bank owes money to some other bank and debentures cannot be liquified. After this fact is comprehended, the rest of the problem boils down to just simulating the process.
Here’s my implementation in C++
:
This was my 200th
solve in UVa
. Alhamdulillah!
Sharing is caring. Share this story in...
Share: Twitter Facebook LinkedIn