today i review the 2179E and 2193E
2179E Balckslex and girls
Apparently, this is a constructive problem. First note that if , then it is impossible.
Then if , we can filling each district with the lower bound number of votes from the designed winner. If we run out of the votes of the either party then the answer is no.
Depart: Case 1: if there is at least one pair of district with different designed winner, we only need to check if the lower bound of the designed winner votes can be achieved.
Case 2: if all district have the same designed winner, we check if .
the attention is all you need
The conditions listed above show the construction of the code. At first we consider the interactively normal case, namely when the winner are all the same person. And then we consider the case 1 to simplified the code.
here are two functions in c++ i haven't seen before:
string(n,'0)//: construct a string with the length of n //and fillled it with char '0'.
accumulate(p+1, p+n+1, 0LL) //:from the position p+1 add to p+1+n and the berginner val is 0.