Problem C video solution (cat, fox and double maximum) : kzbin.info/www/bejne/jHTUdot4q92Liqcsi=9obFRxs5jW8LnrNk
@bishwashkumarsah1717 ай бұрын
other youtubers were just using the one liner but i couldnot understand that. ans = min(p1+p2,(p1+p2+p3)//2). can you explain this solution too that is in the editorial. Nice sol
@cp_with_vkd7 ай бұрын
If you want the explanation for the O(1) solution, it goes like this: As, we are always increasing p1+p2+p3 by 2 (1,1 in case of draw and 2,0 in case of win), the invariant is pretty clear, i.e.., (p1+p2+p3)%2=0 for a valid game. Now, we have p1≤p2≤p3, so we can always have atleast p1 draws. Thus, from p2 and p3, we have to remove p1 points, leaving us with p2+p3−p1 points. Obviously, in the most optimal case, we could have (p2+p3−p1)/2 more draws (if we had equal points left for both), but this is not necessarily the case as it is possible that p2
@dipteshraj91697 ай бұрын
@@cp_with_vkd Absolutely awesome , Now I got it... couldn't understood this o(1) approach by watchinng other yt videos on internet