i is happy only with a slice of size at least appetites[i]. The cake is already cut, and the slice sizes are listed in slices.
Each guest gets at most one slice, and each slice goes to at most one guest. Hand out the slices so that as many guests as possible are happy, and return how many that is.appetites=[4, 2, 6], slices=[3, 5, 1] → 2
Slice 3 goes to the guest with appetite 2 and slice 5 to the guest with appetite 4. Slice 1 is too small for anyone, and no slice is big enough for appetite 6: two guests are happy.
appetites=[3, 3], slices=[] → 0
There is no cake, so nobody is happy.
appetites ≤ 3·10⁴slices ≤ 3·10⁴appetites[i], slices[j] ≤ 2³¹ − 1appetites=[4, 2, 6], slices=[3, 5, 1]
2
Run checks the first 3 tests in your browser. Submit checks all 126 tests on the server, hidden ones included.