Pair of Roses Coding Question C++ STL course

I am getting correct answer for the sample input as well as some of the inputs I tried.

Code - https://ide.codingblocks.com/s/261545

P.S - I have written my logic and algo in comments in the code itself.

It is giving wrong answer on submission. I am unable to figure out what is the problem or where it is failing. Please help me in getting it working or pointing out the case where it may fail.

Consider a test case:
1
3
40 50 30
80

Your O/p:
Deepak should buy roses whose prices are 40 and 40.

Dry run for this case and check your code.

1 Like

Thanks a lot @pratyush63. I totally understood my mistake and corrected it and BOOM, it worked like a charm. Thanks a ton.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.