1. Set-up. Measure ξ from the leading (right) end of the sack, 0 ≤ ξ ≤ L = s1 + s2. Let ρ(ξ) be the unknown weight per unit length. Then ∫0L ρ dξ = Mg and ∫0L ξρ dξ = Mg·s2 (the CM is s2 from the leading end), so ∫0L (L−ξ)ρ dξ = Mg·s1.
2. During the crossing. Let X be how far the leading end has passed the boundary. The weight now resting on the rough floor is w2(X) = ∫0X ρ dξ, and w1(X) = Mg − w2(X) is still on the smooth floor.
3. Pull force. Pulled slowly (quasi-statically), the rope tension equals the total kinetic friction:
F(X) = μ1w1(X) + μ2w2(X), and W = ∫0L F dX.
4. Swap the order of integration. ∫0L w2(X) dX = ∫0L∫0Xρ(ξ) dξ dX = ∫0L ρ(ξ)(L−ξ) dξ = Mg·s1. (Each element of weight spends a length (L−ξ) of the pull sitting on the rough side.) Hence ∫0L w1 dX = MgL − Mg·s1 = Mg·s2.
5. The answer. W = Mg(μ1s2 + μ2s1). Only the first moment of ρ survives, i.e. only the position of the CM — nothing else about how the sand is packed.
6. Two-point check. Replace the sack by two point weights with the same total and the same CM: Mg·s1/L at the leading end and Mg·s2/L at the trailing end. Throughout the crossing F is constant = μ2Mg s1/L + μ1Mg s2/L, so W = L·F = the same. Different F(X) curve, identical area.
7. Sanity limits. s1 → 0 (CM at the leading end) gives W → μ1MgL; s2 → 0 gives W → μ2MgL; s1 = s2 = L/2 gives W = MgL(μ1+μ2)/2. Note the cross pairing: a CM near the leading end makes most of the trip cheap.
8. Idealisations. The carpet is massless and its own friction is ignored (only the sack presses down); the sack neither tips nor lets its sand shift; the pull is slow, so no kinetic energy is left at the end and W is exactly the friction heat. Run-in and run-out are not part of the answer: dragging the whole sack a distance d on the smooth side costs μ1Mg·d, on the rough side μ2Mg·d. g = 10 m/s2.