Blackslex and Girls
From Codeforces. Geometry. Solve the geometry problem "Blackslex and Girls".
Examples
Input: [1,2,3]
Output: 0
Input: [2,3,4]
Output: 0
Hints
Each district i needs minimum p_i voters with strict majority for winner. Minimum winner votes = floor(p_i/2)+1, minimum loser votes = 0, but total must be ≥ p_i.
Allocate mandatory votes first: district i gets p_i total with correct winner majority. Sum minimum A-votes needed for all 0-districts, same for B-votes for 1-districts.
After mandatory allocation, remaining surplus voters can go anywhere. Feasibility check: total mandatory votes ≤ x+y, each party's minimum ≤ available voters of that party.
Blackslex and Girls
**From Codeforces.** Geometry. Solve the geometry problem "Blackslex and Girls".