1399C - Boats Competition I've tried to solve the problem using both maps and unordered_maps The failed code and the accepted code. The accepted code used maps and the failed code uses unordered_maps. But the funny thing is that when I run the code on my machine it gives the correct output while when I submit the code it fails. I know that maps sorts it's elements while unordered_maps don't. Moreover there is no need of sorting the elements as per the question as it requires simple brute force. I've tried to run it on gcc 17 on my machine (hope it helps). P.S. : This is my first blog so please don't downvote it if I,ve made some mistakes cause I really wanna know the answer to this problem. You can let me know in the comment if there is something that needs to be changed.