Nauuo and Cards- Greedy Concept

@Kinjal , no doubt this question is on of the trickiest one , but you don’t have to give up on it. Try for a dry of the code. It will surely help you :slight_smile:

I did dry code for case,

3
0 2 0
1 0 3

3
0 2 0
3 0 1

and that’s why I seek for assistance because I did dry run and it raised my doubts.
Like, how binary search will solve the problem?

So , is there anything else i can help you with?

yeah, if binary search returns 0 or 1 then what is it mean?

If your binary search returns 0 then no operation, if it returns 1 then one operation

Can I get your code on this? Like how you implement binary search on this. Are you implement binary search for all the non zero elements?

I am really sorry for that @Kinjal, as a TA I am prohibited to share my code. But yes I can help you by telling that you can search answer of this problem on codeforces as they would have also implemented the same code . This might help you :grinning:

but you can help me till I understand it.

Yes @Kinjal I am implementing binary search for all the non zero elements

Bhaiya, tell me steps to solve or pseudo code for this problem

Okay now only thing I can do is provide you with source code, but promise me you will dry run it. And mark this doubt as resolved. If this works fine with you, I’ll share my code with you

Bhaiya, I have already seen the code from code forces using binary search and dry run that code. But, I didn’t get that code. If you’re giving me the source code with same logic then there is no point giving me that. My objective here to understand the solution of the problem with someone(TA) who has already done or understand that very well. And I have already notified it on the first place. I will do what you’re saying but I can’t resolve my doubt until I literally get that problem.

this is link: https://codeforces.com/contest/1173/submission/55422470

My code is quite similar to this one

Rest this was the best i could have explained. Sorry if my service disappointed you :slight_smile:

What else i can do is tansfer your doubt to mentor for better service

1 Like

then bhaiya, it means that you understood the code. That’s what I want. So can you kindly tell me the logic of the portion of the code from line no.16!!
Why we are seeing the condition for m[1] only! I mean only,

if(m[1] != -1)

Hey @Kinjal, I have transferred you doubt to mentor. He will reply you as soon as possible

Okay bhaiya…

You’re giving wrong information about, how we are dealing with binary search return value in this problem. You have no idea at all, what’s going on here.