Breadboard Capacity (hard version)

Problem Name:
Breadboard Capacity (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: