NOCHANGE - Editorial

The test case that is mentioned in yrcjkg - Online C++ Compiler & Debugging Tool - Ideone.com is actually wrong as per specifications mentioned in the question.
Test case
1
2 20
4 10.
Answer given as
4 1
That means… 4 * 4 + 1 * 10 = 26. But if we remove one 4 denomination coin, the amount is 3 * 4 + 1 * 10 = 22, which is not strictly less than P which is 20 in this case. The correct answer is NO.
Correct me if I am wrong in any sense @tmwilliamlin

The correct answer for that case, by the “remove one coin” criterion, is
YES 3 1
However the given answer meets the slightly weaker test given in the main text that the total quantity exceeds P but cannot form P exactly.

2 Likes

thanks @joffan … thanks @tmwilliamlin

1 Like

I am unable to understand what is wrong with the logic in this code.
https://www.codechef.com/viewsolution/29832350
I tried all possible scenarios in my understanding.
kindly suggest me testcase where it fails.

You make P into a moving target…

1
2 100
16 20

should obviously give
YES 7 0

Try

Test case

1
2 12
3 4

YES 2 2? Is it right ?

Can you help me with the first test case ? I don’t know why I am wrong ?

Can you explain your code? I can’t understand it.

YES 0 0 0 2 1

Is this a correct solution?

Basically according to my understanding my code is passing every test case. But on submission it is showing wrong answer.

Can you please provide some test cases and its answers to validate my solution?

http://codepad.org/2e7mWFf9
I fixed the bugs. Thank you !

for the case-
1
2 20
4 10
OP->YES 4 1
Should not this be
OP->YES 3 1
You got 4 instead of 3, whereas one 4 can be removed. What do you think? Please correct me if i’m wrong.

That’s why I gave him the test case, he didn’t know why his solution was wrong but his solution incorrectly prints YES 4 1.

can someone tell why we start for loop from (n-1)

for the test case
3 25
3 5 10
can YES 9 0 0 be a valid solution ?