Help needed on USACO Silver 2019 February - Sleepy Cow Herding

Hi! I’ve just been trying to do this problem, got stuck and ended up looking at the solution :sweat_smile: .

However for the following test case which i thought up, the solutions given outputs 2 as the minimum but I can only think of a way using 3 moves.

5
1
2
7
8
10

outputs the following:

2
5

Namely, moving 1 to 4, 2 to 5 and 10 to 6. Just wondering if I’m getting this all wrong or if i misunderstood something.

Thanks!!

You can also move 1 to 6 and 2 to 9.

1 Like

Thanks! cant believe i didnt see that ::