I am trying to solve Problem M: Counting Marbles. I am writing an editorial in case somebody might need it after me, and I am also trying to ask for help in spotting the error in my code. ↵
↵
**Editorial:**: ↵
We are essentially trying to write the smallest base-365 number with the marbles. So we must minimize the earlier digits as much as possible. ↵
↵
Use a priority queue with the tops of the stack, and whenever you use a marble, remove it from the priority queue and put the next element in the queue instead.↵
↵
Please see my solution for one such implementation. ↵
↵
**Help: ↵
**: ↵
My solution is able to run on the sample test cases, but I'm getting WA (could somebody take a look at this)?↵
↵
My solution: https://www.ideone.com/VnKScW ↵
Problem Statement: http://codeforces.me/gym/101889/attachments/download/7471/statements-2017-latam-regional.pdf↵
↵
↵
**Editorial
We are essentially trying to write the smallest base-365 number with the marbles. So we must minimize the earlier digits as much as possible. ↵
↵
Use a priority queue with the tops of the stack, and whenever you use a marble, remove it from the priority queue and put the next element in the queue instead.
↵
↵
**Help
My solution is able to run on the sample test cases, but I'm getting WA (could somebody take a look at this)?↵
↵
My solution: https://www.ideone.com/VnKScW ↵
Problem Statement: http://codeforces.me/gym/101889/attachments/download/7471/statements-2017-latam-regional.pdf↵
↵