Need solution of "The River 1" in C

Can anyone provide the solution of challenge “the river 1” in C or C++. I am gonna be honest I am lost and I cant figure out shit.

there are plenty of hints here:

I suggest trying other easy puzzles if you’re blocked on this one