The Fairest Cut — Solution & Editorial
Subset-sum reachability up to total/2 (bitset DP); the closest reachable sum to half gives difference total − 2·best.
Complexity: O(N · sum / 64) with bitsets
Subset-sum reachability up to total/2 (bitset DP); the closest reachable sum to half gives difference total − 2·best.
Complexity: O(N · sum / 64) with bitsets