Help - Codeforces #674 Div 3 - E - Rock Paper Scissors

Can some one explain how does The minimum number of wins is found out in this code, or any other way to find out. I got how max wins are found

Question Link -Problem - E - Codeforces
AC code - Submission #94157384 - Codeforces

Can you explain like in the minimum case when does A wins?

to find out the minimum score for A just calculate B’s max score - draws, that’s the whole idea and no other logic, there are just different ways to do code it or short cuts to calculate.

the minimum will be n - b’s max - draws.

For each value of R, S and P for B, find the minimum times they could lose.
This is how I did it.

ll mx = min(a1, b2) + min(a2, b3) + min(a3, b1);
ll mn = 0;
ll c1 = n - b1;
mn += max(0ll, a3 - c1);
ll c2 = n - b2;
mn += max(0ll, a1 - c2);
ll c3 = n - b3;
mn += max(0ll, a2 - c3);
cout << mn << " " << mx << "\n";
1 Like